Linux发邮件 通过qq邮箱发邮件

系统+安全 Liemer_Lius 101℃

1、QQ邮箱开启POP3/SMTP服务

在邮箱的设置中找,开通完后,一般会提供授权码,授权码当做密码使用即可。

2、配置文件修改

# vim /etc/mail.rc  # 追加如下内容
set from=330***@qq.com
set smtp=smtps://smtp.qq.com:465
set smtp-auth-user=330***@qq.com
set smtp-auth-password=passwd_for_qq_mail
set ssl-verify=ignore
set nss-config-dir=/root/.certs
set smtp-auth=login

3、生成证书

# mkdir -p /root/.certs/
# echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt
# certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
# certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
# certutil -L -d /root/.certs

4、测试发送邮件

# echo "Hello" | mail -v -s "Alert for work..." 787***@qq.com
Resolving host smtp.qq.com . . . done.
Connecting to 183.3.225.42:465 . . . connected.
Error in certificate: Peer's certificate issuer has been marked as not trusted by the.
Comparing DNS name: "*.mail.qq.com"
Comparing DNS name: "993.dav.qq.com"
Comparing DNS name: "993.eas.qq.com"
Comparing DNS name: "993.imap.qq.com"
Comparing DNS name: "993.pop.qq.com"
Comparing DNS name: "993.smtp.qq.com"
Comparing DNS name: "imap.qq.com"
Comparing DNS name: "mx1.qq.com"
Comparing DNS name: "mx2.qq.com"
Comparing DNS name: "mx3.qq.com"
Comparing DNS name: "pop.qq.com"
Comparing DNS name: "smtp.qq.com"
SSL parameters: cipher=AES-128-GCM, keysize=128, secretkeysize=128,
issuer=CN=GlobalSign Organization Validation CA - SHA256 - G2,O=GlobalSign nv-sa,C=BE
subject=CN=*.mail.qq.com,O=Shenzhen Tencent Computer Systems Company Limited,L=shenzhen,ST=guangdong,C=CN
220 newxmesmtplogicsvrszb5.qq.com XMail Esmtp QQ Mail Server.
>>> EHLO yonsuite-prod-respool-35-53
250-newxmesmtplogicsvrszb5.qq.com
250-PIPELINING
250-SIZE 73400320
250-AUTH LOGIN PLAIN XOAUTH XOAUTH2
250-AUTH=LOGIN
250-MAILCOMPRESS
250 8BITMIME
>>> AUTH LOGIN
334 VXNlcm5hbWU6
>>> MzMwMzAzNDQ3QHFxLmNvbQ==
334 UGFzc3dvcmQ6
>>> d2ZzYWpibWRmc2ZqY2FqZA==
235 Authentication successful
>>> MAIL FROM:<330***@qq.com>
250 OK.
>>> RCPT TO:<787***@qq.com>
250 OK
>>> DATA
354 End data with <CR><LF>.<CR><LF>.
>>> .
250 OK: queued as.
>>> QUIT
221 Bye.

 

转载请注明:skelchina.com » Linux发邮件 通过qq邮箱发邮件

喜欢 (0)