美文网首页
mail 465邮件配置

mail 465邮件配置

作者: cllblogs | 来源:发表于2019-08-24 17:49 被阅读0次

1.开启QQ邮箱SMTP服务

qq邮箱开启SMTP.jpg

然后点击图片右下角生成授权码 ,获取到授权码

2.停止服务

此操作是在root用户下进行

[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
服务 sendmail 信息读取出错:没有那个文件或目录

3.启动postfix服务

此操作是在root用户下进行

# 启动postfix
[root@ruozedata001 ~]# service postfix start 
Redirecting to /bin/systemctl start  postfix.service
Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.

# 查看postfix状态
[root@ruozedata001 ~]# service postfix status
Redirecting to /bin/systemctl status  postfix.service
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   # 这行表示启动失败了
   Active: failed (Result: exit-code) since 六 2019-08-24 16:55:03 CST; 1min 34s ago

8月 24 16:55:01 ruozedata001 systemd[1]: Starting Postfix Mail Transport Agent...
8月 24 16:55:01 ruozedata001 aliasesdb[7204]: /usr/sbin/postconf: fatal: parameter i...:1
8月 24 16:55:02 ruozedata001 aliasesdb[7204]: newaliases: fatal: parameter inet_inte...:1
8月 24 16:55:02 ruozedata001 postfix/sendmail[7206]: fatal: parameter inet_interfaces...1
8月 24 16:55:02 ruozedata001 postfix[7210]: fatal: parameter inet_interfaces: no loc...:1
8月 24 16:55:03 ruozedata001 systemd[1]: postfix.service: control process exited, co...=1
8月 24 16:55:03 ruozedata001 systemd[1]: Failed to start Postfix Mail Transport Agent.
8月 24 16:55:03 ruozedata001 systemd[1]: Unit postfix.service entered failed state.
8月 24 16:55:03 ruozedata001 systemd[1]: postfix.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

# 检查postfix问题
[root@ruozedata001 ~]# postfix check
postfix: fatal: parameter inet_interfaces: no local interface found for ::1

# 需要修改如下配置
[root@ruozedata001 ~]# vi /etc/postfix/main.cf 
...
#inet_interfaces = $myhostname, localhost
#inet_interfaces = localhost 
# 修改为 
inet_interfaces = all

# Enable IPv4, and IPv6 if supported
inet_protocols = all
...

# 重新启动下postfix
[root@ruozedata001 ~]# service postfix start 
# 查看状态
[root@ruozedata001 ~]# service postfix status
...
# 显示启动成功
Active: active (running) since 六 2019-08-24 17:02:08 CST; 10s ago
...

# 配置开机自启动
[root@ruozedata001 ~]# chkconfig postfix on
注意:正在将请求转发到“systemctl enable postfix.service”。

4.创建认证

此操作是在hadoop用户下

[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

[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 certutil -L -d ~/.certs

[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.

5.配置邮件发送者

此操作是在root用户下操作

[root@ruozedata001 ~]$ vi /etc/mail.rc
set from=503757851@qq.com
set smtp=smtps://smtp.qq.com:465
set smtp-auth-user=503757851
#授权码
set smtp-auth-password=xxxxxxxxxx
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/home/hadoop/.certs

6.测试

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

QQ邮箱收到邮件 即表示成功

7.生产使用

  • 发邮件不不带附件
EMAILFROM=503757851@qq.com

EMAILTO=503757851@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}
  • 发邮件带附件
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}

相关文章

  • mail 465邮件配置

    1.开启QQ邮箱SMTP服务 然后点击图片右下角生成授权码 ,获取到授权码 2.停止服务 此操作是在root用户下...

  • qq邮件发送 配置

    (阿里云)服务器上配置了邮件发送,端口25听说是不通的 所以我用465, MAIL_DRIVER=smtpMAIL...

  • 2. mail 465邮件发送案例

    2.mail 465邮件发送案例(含有不带附件和带附件log文件发送) 1. 打开 465端口 2. 进入QQ 邮...

  • 2018-04-26 flask-mail

    flask-mail 1、安装 pip install flask-mail 2、配置 3、异步发送邮件

  • linux16~mailx发邮件带附件

    2018.03.20 生成证书 配置/etc/mail.rc 发邮件

  • springBoot 发送邮件

    全局配置文件: # JavaMailsender 邮件发送的配置 spring . mail .host-smtp...

  • Flask Web Development 第六章读书笔记 电子

    第六章 电子邮件 使用Flask-Mail提供电子邮件支持 TLS和SSL一般使用465,而STARTSSL一般使...

  • FLASK 电子邮件

    安装插件pip install flask-mail 示例邮件信息: 初始化: Flask-Mail的常用配置: ...

  • email

    1. django 发送邮件 settings.py中配置发送邮件邮箱 使用send_mail方法发送邮件

  • Mail 安装配置

    Linux系统环境 Mail功能 1、mail是一款收发邮件的客户端软件 Mail客户端配置文件mail.rc说明...

网友评论

      本文标题:mail 465邮件配置

      本文链接:https://www.haomeiwen.com/subject/fvmqectx.html