运维 -- linux465端口发送qq邮件

1.在QQ账号设置中开启SMTP并获取获取授权码

1.开启POP3/SMTP服务
2.开启IMAP/SMTP服务
3.生成授权码,并保存
在这里插入图片描述


2.关闭 sendmail 服务,并清除开机启动

[root@ruozedata001 ~]# service sendmail stop
Redirecting to /bin/systemctl stop sendmail.service
Failed to stop sendmail.service: Unit sendmail.service not loaded.

[root@ruozedata001 ~]# chkconfig sendmail off
error reading information on service sendmail: No such file or directory

3.启动postfix服务并设置开机启动

[root@ruozedata001 ~]# service postfix start
Redirecting to /bin/systemctl start postfix.service
[root@ruozedata001 ~]# chkconfig postfix on
Note: Forwarding request to 'systemctl enable postfix.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/postfix.service to /usr/lib/systemd/system/postfix.service.
[root@ruozedata001 ~]# postfix check
[root@ruozedata001 ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-08-22 20:43:04 CST; 1h 44min ago
 Main PID: 9274 (master)
   CGroup: /system.slice/postfix.service
           ├─ 9274 /usr/libexec/postfix/master -w
           ├─ 9279 qmgr -l -t unix -u
           └─23101 pickup -l -t unix -u

Aug 22 20:42:58 ruozedata001 systemd[1]: Starting Postfix Mail Transport Agent...
Aug 22 20:43:03 ruozedata001 postfix/postfix-script[9272]: starting the Postfix mail system
Aug 22 20:43:04 ruozedata001 postfix/master[9274]: daemon started -- version 2.10.1, configuration /etc/...fix
Aug 22 20:43:04 ruozedata001 systemd[1]: Started Postfix Mail Transport Agent.
Aug 22 21:25:52 ruozedata001 postfix/pickup[9278]: 847A262DD1B4: uid=0 from=<user@localhost>
Aug 22 21:25:52 ruozedata001 postfix/cleanup[20143]: 847A262DD1B4: message-id=<5d5e97e0.kyriXel40j4k8PTQ...st>
Aug 22 21:25:52 ruozedata001 postfix/qmgr[9279]: 847A262DD1B4: from=<user@localhost.localdomain>, size=...ive)
Aug 22 21:25:53 ruozedata001 postfix/local[20145]: 847A262DD1B4: to=<root@localhost.localdomain>, orig_t...ox)
Aug 22 21:25:53 ruozedata001 postfix/qmgr[9279]: 847A262DD1B4: removed
Hint: Some lines were ellipsized, use -l to show in full.

【注:】systemctl status postfix查看 状态不是 Active: active (running)
需要修改 /etc/postfix/main.cf 这个配置文件

#inet_interfaces = all  改为 inet_interfaces = all
inet_interfaces = localhost 改为 # inet_interfaces = localhost

在这里插入图片描述


4.在自己用户下创建认证

(1).切换到 hadoop 用户
[root@ruozedata001 .certs]# su - hadoop 
Last login: Thu Aug 22 21:01:26 CST 2019 on pts/0
(2).创建认证
[hadoop@ruozedata001 ~]$ mkdir -p ~/.certs/

[hadoop@ruozedata001 ~]$ echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt
depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
verify return:1
depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = GeoTrust RSA CA 2018
verify return:1
depth=0 C = CN, ST = Guangdong, L = Shenzhen, O = Tencent Technology (Shenzhen) Company Limited, OU = R&D, CN = pop.qq.com
verify return:1
DONE

[hadoop@ruozedata001 ~]$ certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt

[hadoop@ruozedata001 ~]$ certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt

[hadoop@ruozedata001 ~]$ certutil -L -d ~/.certs

Certificate Nickname                                         Trust Attributes
                                                             SSL,S/MIME,JAR/XPI

GeoTrust SSL CA                                              C,,  

[hadoop@ruozedata001 ~]$ cd ~/.certs

[hadoop@ruozedata001 .certs]$ certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt
Notice: Trust flag u is set automatically if the private key is present.
[hadoop@ruozedata001 .certs]$ cd ../

5.在/etc/mail.rc中添加qq邮箱发送配置

sudo vi /etc/mail.rc

#qq
set from=xxxxx@qq.com
set smtp=smtps://smtp.qq.com:465
set smtp-auth-user=xxxxx
#授权码
set smtp-auth-password=qq邮箱授权码
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/home/hadoop/.certs

6.验证

[hadoop@ruozedata001 ~]$ echo hello word | mail -s " title" xxxx@qq.com

在这里插入图片描述


7.发送不带附件的邮件(mail)

EMAILFROM=xxxx@qq.com
EMAILTO=yyyy@qq.com

echo -e "`date "+%Y-%m-%d %H:%M:%S"` : The current running $JOB_NAME job num is
$RUNNINGNUM in 192.168.137.201 ......" | mail \
-r "From: alertAdmin <${EMAILFROM}>" \
-s "Warn: Skip the new $JOB_NAME spark job." ${EMAILTO}

在这里插入图片描述


8.发送带附件的邮件(mailx)

EMAILFROM=xxx@qq.com
EMAILTO=yyyyy@qq.com
echo -e "`date "+%Y-%m-%d %H:%M:%S"` : Please to check the fail sql attachement." | mailx \
-r "From: alertAdmin <${EMAILFROM}>" \
-a error.log \
-s "Critical:KSSH fail sql." ${EMAILTO}

在这里插入图片描述


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值