Install and configure sendmail
Yuminstall-ysendmailsendmail-cfm4
Set network access permissions for the Sendmail service
vi /etc/mail/sendmail.mc
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1,Name=MTA')dnl
Change 127.0.0.1 to 0.0.0.0, which means that any host can access the Sendmail service. If only one CIDR block can access the Sendmail service, change 127.0.0.1 to a specific CIDR block address, such as 192.168.1.0/24.
Generate the Sendmail configuration file
The configuration file of Sendmail is generated by m4, And the m4 tool is in the sendmail-cf package. If the system cannot identify the m4 command, the sendmail-cf package is not installed.
Generate the configuration file for Sendmail:
M4/Etc/mail/sendmail. mc>/Etc/mail/sendmail. cf
You must restart Sendmail to make the configuration file take effect.
Service sendmail restart
Add the machine name to/etc/hosts.
echo "" >>/etc/hosts
echo "127.0.0.1 $HOSTNAME" >>/etc/hosts
Iptables configuration
iptables-A INPUT -p tcp --dport 25 -j ACCEPT
iptables-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
serviceiptablessave
service iptables restart
Test Email:
mail -s "hosts" xxxx@qq.com < /etc/hosts