CentOS installation SendMail and use detailed

Source: Internet
Author: User
Tags aliases auth md5 message queue centos

Install SendMail

1. Installation:

The code is as follows Copy Code

#yum install-y SendMail
#yum install-y SENDMAIL-CF
Install and start the SASLAUTHD service if SMTP authentication is required:
# yum Install-y SASLAUTHD
# service SASLAUTHD Start

2, configuration

(1) Configure Senmail SMTP authentication

The code is as follows Copy Code

# VI/ETC/MAIL/SENDMAIL.MC

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 two lines above. In the SendMail file, DNL indicates that the behavior comment line is invalid, so you can open the corresponding set line by removing the DNL string at the beginning of the row.

(2) Set the network access rights of the SendMail service (since I am a direct native call so I did not operate this step)

The code is as follows Copy Code

# VI/ETC/MAIL/SENDMAIL.MC

Daemon_options (' port=smtp,addr=127.0.0.1, Name=mta ') dnl

Changing 127.0.0.1 to 0.0.0.0 means that any host can access the SendMail service. If only one segment of the network can access the SendMail service, change 127.0.0.1 to a specific network segment address that is shaped like 192.168.1.0/24.


3. Generate Configuration file

The SendMail configuration file is generated by M4, and the M4 tool is in the SENDMAIL-CF package. If the M4 command is not recognized by the system, the SENDMAIL-CF package is not installed.

The code is as follows Copy Code

#m4/ETC/MAIL/SENDMAIL.MC >/ETC/MAIL/SENDMAIL.CF

4, start the service

The code is as follows Copy Code

#service SendMail Start

Check to see if the service is joined to the self-starter queue

The code is as follows Copy Code

#chkconfig--list |grep SendMail

Test Send Mailbox

Method 1 installs SendMail to be able to use,

The code is as follows Copy Code
Mail-s "Test" user@sohu.com <content.txt

Bin/mail will use the local sendmail to send mail by default, which requires local machines to install and start the SendMail service, is cumbersome to configure, and can result in unnecessary resource consumption.


Method 2. Leverage external SMPT servers

By modifying the configuration file, you can use an external SMTP server to send mail with an external SMTP server without using SendMail:

Modify/etc/nail.rc (/etc/mail.rc)

The code is as follows Copy Code
Set from=fromuser@domain.com smtp=smtp.domain.comset smtp-auth-user=username smtp-auth-password=passwordset Smtp-auth=login

Description

From is the mailing address sent

SMTP is the address of the external SMTP server that occurred

Smtp-auth-user is the user name authenticated by the external SMTP server

Smtp-auth-password is an external SMTP server authenticated user password

Smtp-auth is the way of email authentication

Once the configuration is successful, you can use the

You can send an e-mail to test:

The code is as follows Copy Code

Mail-s "Test" username@163.com <content.txt where the-S is the message header, User@sohu.com is the recipient's address, Content.txt is the message body

Character encoding

In sending a Chinese message, character encoding is a more important issue, and if it is not set correctly, the message header or message content will appear garbled.

The encoding of the message content can be set in the message header Content-type, such as setting the message content to UTF-8 encoding:

The code is as follows Copy Code

Content-type:text/html;charset=utf-8


In the message header, such as From,to,subject, if you need to use Chinese, you can set this:

The code is as follows Copy Code

=? UTF-8? B? " +base64encode (Content UTF8 code) + "? ="

From: =? UTF-8? b?5l2g5aw9?= Www.111cn.nert <jdoe@machine.example>
Sender:michael Jones <mjones@machine.example>
To:mary Smith <mary@example.net>
Content-type:text/html;charset=utf-8
Subject: =? UTF-8? b?5l2g5aw9?=

<div style= "Border:solid 1px #1D448C;" >
<p>so, "Hello" .</p>
</div>


sendmail Configuration Parameters


1. Free block number with minimum configuration
Configuration parameters: Minfreeblocks
Parameter description: The minimum number of free blocks in a queue that the file system uses to accept standard SMTP (Simple Mail Transfer Protocol) messages.
The smaller the more likely to be attacked deadly.
Default value: 100
Recommended value: 4000 or greater

2. Maximum message size
Configuration parameters: MaxMessageSize
Parameter description: The maximum size of each message, in bits (bytes). The bigger the attack, the more likely it is to be deadly.
Default value: No Limit
Recommended value: 5M

3. Automatically recreate aliases
Configuration parameters: Autorebuildaliases
Parameter description: Automatically recreate all aliases when needed. If set to true, this is a potential crisis that can cause a denial of service attack.
Default value: False
Recommended value: False

4. Queue Average Load
Configuration parameters: Queuela
Parameter description: The average load at a single queue. According to the number of CPUs properly set (8*cpu quantity)
Default value: Variable
Recommended value: 10*cpu quantity

5. Average load rejection critical point
Configuration parameters: Refusela
Parameter description: Once the average load exceeds this critical point, all incoming SMTP connections are rejected.
Default value: Variable
Recommended value: 8*cpu quantity

6. Number of child processes for the maximum daemon process
Configuration parameters: Maxdaemonchildren
Parameter description: The maximum number of child processes allowed to fork. When this number is exceeded, the connection is rejected. If the set value is less than or equal to zero, it means no limit.
Default value: Not Defined
Recommended value: Set according to memory size. (for example, 128M memory recommended value is 40)

7. Maximum header length
Configuration parameters: Maxheaderslength
Parameter description: Maximum total length of all headers
Default value: Not set
Recommended value: 32 or 64K

8. Maximum MIME encoded message length
Mime,multipurpose Internet Mail Extension Protocol, Multipurpose Internet Messaging Extensions Protocol
Configuration parameters: Maxmimeheaderlength
Parameter description: The maximum message length after MIME encoding
Default value: Not Defined
Recommended value: 1024 or smaller

9. Maximum number of recipients per email
Configuration parameters: Maxrecipientspermessage
Parameter description: If set, each message can be copied to the specified number of addressee at the same time. Exceeding this number returns an error code of 452. That is, in a message queue, it is sent indefinitely.
Default value: Not set
Recommended value: 10-100

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.