zoukankan      html  css  js  c++  java
  • 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等。

  • 相关阅读:
    grunt in webstorm
    10+ Best Responsive HTML5 AngularJS Templates
    响应式布局
    responsive grid
    responsive layout
    js event bubble and capturing
    Understanding Service Types
    To add private variable to this Javascript literal object
    Centering HTML elements larger than their parents
    java5 新特性
  • 原文地址:https://www.cnblogs.com/su-root/p/10092469.html
Copyright © 2011-2022 走看看