Configure sendmail to send emails in CentOS6.x

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.