sudo apt-get install sendmail
sudo apt-get install sendmail-cf
The following packages are optional:
squirrelmail //Provide webmail spamassassin //Provide mail filtering mailman //Provide mailing list support dovecot //Provide IMAP and POP receiving mail server daemon
squirrelmail //Provide webmail spamassassin //Provide mail filtering mailman //Provide mailing list support dovecot //Provide IMAP and POP receiving mail server daemon Note:
To use the most commonly used mail function under Ubuntu, you need to install mailutils,
Installation command: sudo apt-get install mailutils
To use the function with accessories, you also need to install sharutils,
Installation command: sudo apt-get install sharutils; (yum install sharutils)
Terminal input command: ps aux |grep sendmail
The 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
Explain that sendmail has been successfully installed and started
Two, configuration
By default, sendmail will only send mail for local users. Only by extending it to the entire Internet can it become a real mail server.
Open the sendmail configuration macro file: /etc/mail/sendmail.mc
vi /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 to indicate that it can connect to any server.
Generate a new configuration file:
m4 sendmail.mc> sendmail.cf //Make a backup #m4 sendmail.mc> sendmail.cf //> There are spaces on the left and right sides, indicating an error that sendmail-cf is not installed
Three, test sending mail
Common ways to send mail are as follows:
In addition, it should be noted that the domain name used by sendmail is modified accordingly. The system defaults to localhost.localdomain. In fact, it does not need to be changed. However, some pop3 servers will filter out the emails from localhost.localdomain, which will cause the emails to not be checked normally. Fortunately, change the hostname to ensure the success rate of email sending.
The following is the modified configuration of my online machine for reference.
127.0.0.1 met.com localhost.localdomain localhost
The content of /etc/hosts generally has the following similar content:
127.0.0.1 localhost.localdomain localhost
Each line consists of three parts, each part is separated by a space.
The format is
IP address host name/domain name host name alias
That is, the first part: network IP address; the second part: host name or domain name; the third part: host name alias;
Then we need to modify it to our own domain name. Taking server110.com as an example, we will modify it to the following format:
127.0.0.1 server110.com localhost
# cat /etc/mail/access
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1
Connect:met.com RELAY
# cat /etc/mail/local-host-names
met.com
After the modification is completed, restart the sendmail service and use the telnet command to test to see if it has taken effect
# telnet 127.0.0.125
Trying 127.0.0.1...
Connected to met.com(127.0.0.1).
Escape character is '^]'.220 met.com ESMTP Sendmail 8.13.8/8.13.8; Sun,10 Oct 201014:00:33+0800
From the above results, we can find that localhost.localdomain has become the domain name of met.com, indicating that the modification is successful
PS:
If an error is reported when using the sudo command: sudo: unable to resolve host webank.pw
It is because the two files /etc/hostname and /etc/hosts do not contain webank.pw
PS:
Author server successfully configured example:
youhong@webank$ cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
127.0.0.1 webank.pw
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost TENCENT.site TENCENT ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
youhong@webank$ cat /etc/hostname
webank.pw
At this point, you can use the mailbox with domain name to send mail to other mailboxes.
**About sendmail logs and configuration files: **
After sendmail is successfully installed by default, its log is under /var/log, which records various logs of sendmail, and its configuration files are mainly distributed under the /etc/mail path.
Recommended Posts