美文网首页
redhat6使用SMTP发送邮件

redhat6使用SMTP发送邮件

作者: snopy | 来源:发表于2016-07-25 14:04 被阅读0次

    1、关闭sendmail和postfix

    1) sendmail

    service sendmail stop
      chkconfig sendmail off #关闭开机启动

    2) postfix

    service postfix stop
      chkconfig postfix off

    2、安装mailx

    redhat6上安装mailx:
      yum install mailx

    3、邮箱端配置(smtp服务可用网易或者QQ的,推荐使用QQ的smtp,网易经常会出现554的报错而将邮件退回)

    1) 使用网易邮箱SMTP服务

    配置过程如下:
    第一步:在163邮箱设置-->账户中开启pop3/smtp服务,并记下客户端授权密码
    第二步:vim /etc/mail.rc 在文件最后添加你的邮箱信息:
    使用网易SMTP服务(经常被误认为垃圾邮件):
    set from=150*@163.com
    set smtp=smtp.163.com
    set smtp-auth-user=150*@163.comset
    smtp-auth-password=Your password (注意:此处为客户端授权密码)
    set smtp-auth-login

    2)使用QQ邮箱SMTP服务

    获取证书文件:
    mkdir -p /root/.certs/
    echo -n | openssl s_client -connect 14.18.245.164: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

    配置mail.rc:
    vim /etc/mail.rc
    set from=150*@qq.com
    set smtp=14.18.245.164       #smtp.qq.com对应的ip(用于服务器不能连接外网解析域名的情况)
    set smtp-auth-user=150*@qq.com
    set smtp-auth-password=your passwd
    set smtp-auth-login
    set smtp-use-starttls
    set ssl-verify=ignore
    set nss-config-dir=/root/.certs

    备注:如出现“Error initializing NSS: Unknown error -8015.”是因为用户权限的问题。
    解决办法:chmod -R 777 /root/.certs

    4、测试发送邮件:

    echo "hello" |mailx -s 'test a mail' example.com
    mailx -s 'test a mail' example.com <filename
    (符号"<"和文件名之间千万不要有空格,否则会被列为垃圾邮件)

    相关文章

      网友评论

          本文标题:redhat6使用SMTP发送邮件

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