CentOS sendmail installation and email domain name Configuration

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

Sendmail is an excellent Mail System in Linux. Without any setup, the source address of the sendmail e-mail address is like a userid@localhost.localdo, which is identified as SPAM or rejected by almost all mailboxes.

1. Install Sendmail

In CentOS, sendmail is generally installed with the operating system by default. If the sendmail service is not installed when installing the system, it is easy to manually install sendmail:

view plain  copy
  
  
  1. # yum install -y sendmail

  2. # yum install -y sendmail-cf

2. Configure SMTP authentication for Senmail (skip this step if authentication is not required)

First, check whether the saslauthd service is installed or started.

Install the 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 
   
  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 rows. In the sendmail File, dnl indicates that the behavior comment line is invalid. Therefore, you can enable the corresponding setting line by removing the dnl string at the beginning of the line.

(2) Set network access permissions for the Sendmail service

# Vi/etc/mail/sendmail. mc

view plain copy 
   
  1. 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.

3. 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:

view plain copy 
    
  1. m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

You must restart Sendmail to make the configuration file take effect.

4. Sendmail mail domain name Configuration

To configure sendmail to use a valid domain name, you can modify the configuration file of sendmail and add the domain name MX record.

Sendmail can directly use the "-r account@domain.com" parameter to send mail at any source address, but the current mainstream mailbox will compare the source address and reverse resolution IP, if the email cannot be parsed or the resolved IP address does not match, the email is directly classified as SPAM. If the email is serious, the email is rejected.

MX Record is mainly used to receive emails. When a new email is delivered, the MX Record of the recipient's domain name is queried and then delivered through the IP address obtained from the MX Record. At the same time, the email manufacturer will compare the source address with the MX record when receiving the mail, as one of the criteria for determining the spam mail.

Step 1: Add a domain name

(1) Add the domain name to the local-host-names File

# Vi/etc/mail/local-host-names, add

view plain copy 
    
  1. sunchis.com

(2) modify the submit. cf file

# Vi/etc/mail/submit. cf, find the line # Dj $ w. Foo. COM, and change it

view plain copy 
    
  1. Djsunchis.com

So far, the sendmail mail naming configuration is complete, and restart sendmail to make the configuration take effect.

Step 2: add the domain name MX record

Find the page for modifying Domain Name Information (different domain name registrar pages are different). The Modification result will take effect within 24 hours at the latest because of different domain name providers.

(1) Add the domain name A record mail and direct it to the static IP address of your email server:

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

(3) Use nslookup to check whether MX records can be correctly resolved to the email server

view plain copy 
    
  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 = 10 mail.sunchis.com.

  8. Authoritative answers can be found from:

  9. >

OK. The email server's domain name has been correctly resolved.

5. Resolution of Relaying denied

550 5.7.1 <xxx@163.com>... relaying denied. IP name lookup failed [192.168.1.20.] is abnormal because sendmail is used as the mail transfer station and the client IP address must be added to the access configuration file.

# Vi/etc/mail/access, add

view plain copy 
    
  1. Connect:192.168.1.133 RELAY

Regenerate the database with access permissions:

view plain copy 
    
  1. # cd /etc/mail/

  2. # makemap hash access.db < access

In this way, the problem will be solved.


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.