• Centos 配置mailx使用外部smtp发送邮件


    今天写定时脚本时,用到监控服务器是否备份成功,配置sentmail和postfix总是出问题,原本想只是接受个信息,没必要那么麻烦,直接配置mailx就能满足了,具体配置如下:

    1、安装mailx

    yum install mailx -y 

    2、编辑发送的配置文件(修改/etc/mail.rc)

    vi /etc/mail.rc

    #qq.com

    set smtp=smtp.qq.com    //邮箱所在服务器和端口地址

    set from="1147076062@qq.com"  //你的qq邮箱

    set smtp-auth-user="1147076062@qq.com" smtp-auth-password="bqh***"  //邮箱密码

    set smtp-auth=login  //默认login即可

    echo "邮件正文" | mail -s "邮件主题" 1147076062@qq.com

    发送文件的另外几种格式:

    cat file.txt | mail -s "邮件主题" 1147076062@qq.com

    mail -s "邮件主题" 1147076062@qq.com < file.txt

    echo  hello 锦衣卫 | mail -s "测试" 1147076062@qq.com

    温馨提醒:

    ①记得要进邮箱打开SMTP。

    ②关闭本机的sendmail服务或者postfix服务等。

    ③smtp-auth-password="bqh***" 此处是配置授权码,而不是邮箱的独立密码。如果配置错了会报错

    smtp-server: 535 Error: ȫʹԃ˚ȨëµȂ¼¡£Ъȩȫ¿´: http://service.mail.qq.com/cgi-b

    in/help?subtype=1&&id=28&&no=1001256"/root/dead.letter" 11/303
    . . . message not sent.

    ---------------------------------------------------------------------------------------------------------

    想让服务器自动发个邮件至163邮箱或者qq邮箱等,可以配置mailx使用外部smtp发送邮件,要是想做邮件服务器的话可以用sentmail和postfix等。

  • 相关阅读:
    课程作业02
    课后作业01
    大道至简第一章伪代码
    《大道至简》读后感
    Codeforces 959 F. Mahmoud and Ehab and yet another xor task
    Codeforces 992 E. Nastya and King-Shamans
    Codeforces 835 F. Roads in the Kingdom
    Codeforces 980 D. Perfect Groups
    洛谷 P4315 月下“毛景树”
    JDOJ 1234: VIJOS-P1052 高斯消元
  • 原文地址:https://www.cnblogs.com/su-root/p/10092469.html
Copyright © 2020-2023  润新知