In ubuntu sendmail function can easily send e-mail, sendmail ubuntu first install the two packages.
Installation of the required two packages:
- sudo apt-get install sendmail
- sudo apt-get install sendmail-cf
Here are a few optional packages:
- squirrelmail // provide webmail
- spamassassin // provide spam filtering
- mailman // provide support mailing list
- dovecot // provide POP and IMAP incoming mail server daemon
note:
- Ubuntu under the most commonly used mail function, you need to install mailutils,
- Installation command: sudo apt-get install mailutils
- Use functional band attachments, also need to install for sharutils,
- Installation command: sudo apt-get install sharutils; (yum install sharutils)
Input terminal command: ps aux | grep sendmail
output is as follows:
root 20978 0.0 0.3 8300 1940 ? Ss 06:34 0:00 sendmail: MTA: accepting connections
root 21711 0.0 0.1 3008 776 pts/0 S+ 06:51 0:00 grep sendmail
Description sendmail has been successfully installed and started
Second, the configuration
sendmail default will send a message-oriented user machine, only to extend it to the entire Internet, will become a real mail server.
Macro open sendmail configuration file: /etc/mail/sendmail.mc
we /etc/mail/sendmail.mc
Find the following line:
- DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl
Modify Addr = 0.0.0.0, indicate that can connect to any server.
Generate a new configuration file:
- #cd / etc / mail
- #mv sendmail.cf sendmail.cf ~ // do a backup
- # M4 sendmail.mc> sendmail.cf //> around a space, an error is not installed sendmail-cf
Third, test sending mail
Used to send mail as follows:
1. How to write a general e-mail: mail [email protected] Cc Cc edit objects, Subject: message subject, press enter, the body of the message, press Ctrl-D end
2. Fast sending mode: echo "Message Body" | mail -s message subject [email protected]
3. contents of the file as a text message to send: mail -s the Test [email protected] <test.txt
4. Send e-mail with attachments: uuencode attachment attachment name displays the name | mail -s thread Send e-mail address
例如: uuencode test.txt test.txt | mail -s Test [email protected]
Attention to the problem:
1)
If you find that your sendmail start very slow, can be resolved
# vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
changed to
127.0.0.1 localhost.localdomain localhost host name
Check the host name of the machine the command is: hostname
Leaving only the line on the line, you can delete the extra row
2)
*** ERROR: FEATURE() should be before MAILER()
*** MAILER(`local') must appear after FEATURE(`always_add_domain')*** ERROR: FEATURE() should be before MAILER()
*** MAILER(`local') must appear after FEATURE(`allmasquerade')*** ERROR: FEATURE() should be before MAILER()
The last few lines to modify sendmail.mc
vi /etc/mail/sendmail.mc
the document
MAILER_DEFINITIONS
MAILER ( `local ') DNL
MAILER (` the SMTP') DNL
into the final document (Why do so, the reason is not found, but an error the prompt that asks you to do so)