Ali goes through the port 465 to send messages to bypass port 25

Reference links

Ali cloud using ECS ​​webmasters should know that Ali cloud ECS in order to prevent it being used as a server to send spam mail servers prohibit the use of port 25, which resulted in system-level reminder messages can not be sent, similar Fail2ban, DDoS Deflate important brute force, DDOS attack reminder emails sometimes still very important, we will miss the server operation and maintenance work to bring passive, so the moon has been seeking to solve the problem in the Linux system messages sent.

Installation and configuration of the system mailx:

yum -y install mailx

After installation is complete, edit the configuration file /etc/mail.rc mailx use QQ mailbox to send mail as the mailbox, in the config file add the following configuration to QQ-mail:

set [email protected]
set smtp=smtps://smtp.qq.com:465
set [email protected]
set smtp-auth-password=你的QQ邮箱授权码
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/opt/.certs

Configuration smstps

Ali cloud ECS banned because the port 25, so we can only use TLS mode (TSL is using SSL encryption method, using 465 or other ports to send messages) to bypass port 25 needs to send mail, you must first obtain the mailbox SSL certificate into the local co-exist, the last line of nss-config-dir is to develop storage location QQ mailbox SSL certificate.

mkdir -p /opt/.certs/
echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /opt/.certs/qq.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d  /opt/.certs -i /opt/.certs/qq.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d /opt/.certs -i /opt/.certs/qq.crt
certutil -L -d /opt/.certs
chmod -R 777 /opt/.certs   #让所有用户都可以发邮件

In order to prevent the emergence of the text before sending mail warning said, also need to enter the mail store directory /opt/.certs SSL certificate in the following command:

certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt

You can return the following tips:

**Notice: Trust flag u is set automatically if the private key is present.**

So far, the combination has been completed mailx QQ mailbox to send mail systems deployed by the command line to send test messages Try it:

mailx -s "Mailbox test" [email protected] <message_file.txt

Guess you like

Origin www.cnblogs.com/johnsonjie/p/11280098.html