CentOS SendMail installation and mail domain configuration

Source: Internet
Author: User
Tags ip name lookup mx record nslookup



Http://www.centoscn.com/CentosServer/lighttpd/2013/0726/650.html






SendMail is an excellent mail system under Linux. In the case of no setting, the email source address of SendMail e-mail is like [email protected], which will almost be identified by all the mailboxes as spam (spam) or directly rejected.



1, SendMail Installation



Under CentOS, SendMail is typically installed with the operating system by default. If the SendMail service is not installed when the system is installed, manually installing SendMail is also simple:


View PlainCopy
    1. # yum Install-y sendmail

    2. # yum Install-y sendmail-cf


2, Senmail SMTP authentication configuration (do not need authentication to ignore this step)



First verify that the SASLAUTHD service is installed or started.



Install SASLAUTHD service: # yum Install-y SASLAUTHD



Start SASLAUTHD Services: # service SASLAUTHD start



(1) Configuring SMTP authentication for Senmail



# VI/ETC/MAIL/SENDMAIL.MC


View PlainCopy
    1. DNL Trust_auth_mech (' EXTERNAL digest-md5 cram-md5 LOGIN PLAIN ') dnl

    2. DNL define (' confauth_mechanisms ', ' EXTERNAL GSSAPI digest-md5 cram-md5 LOGIN PLAIN ') dnl


Remove the DNL from the above two lines. In the SendMail file, DNL indicates that the behavior comment line is invalid, so you can open the corresponding setting line by removing the DNL string at the beginning of the row.



(2) Setting up network access for SendMail services



# VI/ETC/MAIL/SENDMAIL.MC


View PlainCopy
    1. Daemon_options ('port=SMTP,addr=127.0.0.1, name=MTA ') dnl


Change 127.0.0.1 to 0.0.0.0, meaning that any host can access the SendMail service. If only one segment is allowed to access the SendMail service, change 127.0.0.1 to a specific segment address that is shaped like 192.168.1.0/24.



3. Generate SendMail configuration file



The SendMail configuration file is generated by M4 and the M4 tool is in the SENDMAIL-CF package. If the system does not recognize the M4 command, it indicates that the SENDMAIL-CF package is not installed.



To generate a SendMail configuration file:


View PlainCopy
    1. M4/ETC/MAIL/SENDMAIL.MC >/ETC/MAIL/SENDMAIL.CF


A restart of SendMail is required for the configuration file to take effect.



4, sendmail mail domain name configuration



Configure SendMail to use a legitimate domain name in two steps, modify the SendMail profile and add the domain name MX record.



SendMail can directly use the "-R [E-Mail protected]" parameter to send mail at any source address, but the current mainstream mailbox will be the source address and reverse resolution IP comparison, if the resolution is not resolved or the IP mismatch, light will be directly classified as spam mail, Serious will directly refuse to receive.



The MX record (mail Exchanger record) is primarily used when mail is received, that is, when a new message is posted, the MX record of the recipient's domain name is queried and then posted via the IP address obtained by the MX record. At the same time, the mail maker will also compare the source address and MX record when receiving the mail, as one of the criteria of spam judgment.



First step: Add a domain name



(1) Adding a domain name to the Local-host-names file



# vi/etc/mail/local-host-names, adding


View PlainCopy
    1. Sunchis.com


(2) Modify the submit.cf file



# VI/ETC/MAIL/SUBMIT.CF, find the line #Dj $w. foo.com, modified to


View PlainCopy
    1. Djsunchis.com


At this point, the SendMail message naming configuration is complete, and restarting SendMail makes the configuration effective.



Step Two: Add the domain name MX record



Find the page to modify the domain name information (different domain name Registrar page is not the same), the results of the changes will be effective in 24 hours at the latest due to the different domain name vendors.



(1) Add the domain A record mail, pointing directly to your mail server's static IP address:



(2) Add (or modify) The MX record of the domain name, such as:



(3) Use Nslookup to detect if the MX record resolves correctly to the mail server


View PlainCopy
    1. # nslookup

    2. > Set q=mx

    3. > sunchis.com

    4. server:8.8.8.8

    5. address:8.8.8.8#53


    6. Non-authoritative Answer:

    7. Sunchis.com mail exchanger = ten mail.sunchis.com.


    8. Authoritative answers can found from:

    9. >


OK, the domain name corresponding to the mail server has been resolved correctly.



5, relaying denied (refuse delivery) of the resolution



Appear 550 5.7.1 <[email protected]> Relaying denied. IP name lookup failed [192.168.1.133] exception, because the SendMail as a mail broker, you need to add the client's IP address to the access configuration file.



# vi/etc/mail/access, adding


View PlainCopy
    1. connect:192.168.1.133 RELAY


To regenerate access to the database:


View PlainCopy
    1. # cd/etc/mail/

    2. # makemap Hash access.db < access


In this way, the problem will be solved.





Sendmail is an excellent mail system under Linux. Without any settings, the email source address of sendmail is like [email protected], which will be recognized as spam or rejected directly by almost all mailboxes.
1. Sendmail installation
Under CentOS, sendmail is generally installed with the operating system by default. If the sendmail service is not installed when the system is installed, it is also easy to install sendmail manually:
view plain   copy
# yum install -y sendmail
# yum install -y sendmail-cf
2. SMTP authentication configuration of senmail (ignore this step if authentication is not required)
First, verify that the saslauthd service is installed or started.
Install saslauthd service: ා Yum install - y saslauthd
Start saslauthd service: ා service saslauthd start
(1) Configure SMTP authentication for senmail
# vi /etc/mail/sendmail.mc
view plain   copy
dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN‘)dnl
dnl define(`confAUTH_MECHANISMS‘, `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN‘)dnl
Remove the DNL from the above two lines. In the sendmail file, DNL indicates that the comment line is invalid, so the corresponding setting line can be opened by removing the DNL string at the beginning of the line.
(2) Set network access for sendmail service
# vi /etc/mail/sendmail.mc
view plain   copy
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA‘)dnl
Change 127.0.0.1 to 0.0.0.0, which means any host can access the sendmail service. If only one segment can access the sendmail service, change 127.0.0.1 to a specific segment address like 192.168.1.0/24.
3. Generate sendmail profile
The configuration file of sendmail is generated by M4, and the M4 tool is in the sendmail CF package. If the system does not recognize the M4 command, the sendmail CF package is not installed.
To generate a profile for sendmail:
view plain   copy
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Sendmail needs to be restarted for the profile to take effect.
4. Sendmail mail domain name configuration
There are two steps to configure sendmail to use a legal domain name: modifying the configuration file of sendmail and adding the domain name MX record.
Sendmail can directly use the "- R [email protected]" parameter to send mail at any source address, but at present, the mainstream mailbox will compare the source address with the reverse resolved IP address. If the resolved IP address fails or does not match, the mail will be directly classified as spam, and the serious one will be directly rejected.
MX record is mainly used when receiving mail, that is, when a new mail is delivered, MX record of the recipient's domain name will be queried, and then the IP address obtained through MX record will be delivered. At the same time, mail manufacturers will also compare the source address and MX record when receiving mail, as one of the criteria of spam.
Step 1: add domain name
(1) Add the domain name to the local host names file
#VI / etc / mail / local host names, adding
view plain   copy
Sunchis.com
(2) Modify the submit.cf file
#VI / etc / mail / submit.cf, find the line ා DJ $w.foo.com, and change it to
view plain   copy
Djsunchis.com
At this point, sendmail mail naming configuration is completed, restart sendmail to make the configuration effective.
From: http://www.sunschis.com/html/os/linux/2012/0503/407.html 





CentOS SendMail installation and mail domain configuration


Related Article

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.