First, 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:
# yum Install-y sendmail
# yum Install-y sendmail-cf
Second, 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
Third, the use of features with accessories, you also need to install Sharutils
#yum Install Sharutils
Iv. Configuring SMTP authentication for Senmail
# VI/ETC/MAIL/SENDMAIL.MC
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.
V. Setting up network access for SendMail services
# VI/ETC/MAIL/SENDMAIL.MC
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.
Vi. Generating SendMail configuration files
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:
1. M4/ETC/MAIL/SENDMAIL.MC >/ETC/MAIL/SENDMAIL.CF
A restart of SendMail is required for the configuration file to take effect.
Vii. sendmail Mail Domain 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
1. yaokj.com
(2) Modify the submit.cf file
# VI/ETC/MAIL/SUBMIT.CF, find the line #Dj $w. foo.com, modified to
1. djyaokj.com
At this point, the SendMail message naming configuration is complete, and restarting SendMail makes the configuration effective.
# Service SendMail Restart
Eight, test:
1. How to write General mail: Mail [email protected] cc Edit CC object, Subject: Message subject, enter carriage return, message body, press ctrl-d end
2. Quick send: echo "message body" | mail-s email subject [Email protected]
3. Send the file content as the message body: mail-s test [email protected] < Test.txt
4. Send mail with attachments: # mail-s test-a test.txt [email protected] Enter, message body press ctrl-d end
Install sendmail send mail under Linux