美文网首页
Linux 配置sendmail发送邮件

Linux 配置sendmail发送邮件

作者: 小马将过河 | 来源:发表于2020-04-18 14:23 被阅读0次

    Ubuntu 安装工具

    apt-get install heirloom-mailx
    

    修改配置

    vim /etc/s-nail.rc在文件最后加入如下配置项:

    set from="mailtest@3vyd.com"
    set smtp="smtp.exmail.qq.com"
    set smtp-auth-user="mailtest@3vyd.com"
    set smtp-auth-password="xxxx"
    set smtp-auth=login
    

    测试邮件

    echo "测试的邮件内容" | s-nail  -s "测试的邮件主题" marvin.ma@redcreation.net
    
    mail

    注意

    root@hk-server:~# Could not connect: Operation now in progress
    “/root/dead.letter” 8/209
    … message not sent

    这里注意!因为是阿里云服务器,可能是25端口被封,得改用465端口,所以配置内容那里要注意将smtp配置加上端口:

    set smtp=smtp.exmail.qq.com:465
    

    centos

    1. install Mailx
    yum install -y mailx
     
    
    1. Config SMTP Params
    vi /etc/mail.rc
    
    # Add Gmail SMTP
    set from=yiilib.com_t@gmail.com  #send from mail address
    set smtp=smtp.gmail.com    #SMTP server domain
    set smtp-auth-user=yiilib.com_t  #send account
    set smtp-auth-password=mailBoxPassword  #account password
    set smtp-auth=login     #auth way
     
    
    1. send test
    echo "mail body" | mail marvin.ma@redcreation.net -s "test mail subject" -a /root/backup/yiilib.com_tmp.sql
    

    两种常用配置

    • 腾讯企业邮箱
    set from="mailtest@3vyd.com"
    set smtp="smtp.exmail.qq.com"
    set smtp-auth-user="mailtest@3vyd.com"
    set smtp-auth-password="xxxx"
    set smtp-auth=login
    
    • 163网易邮箱(密码是指客户端授权密码)
    set from="chuangkehui@163.com"
    set smtp="smtp.163.com"
    set smtp-auth-user="chuangkehui@163.com"
    set smtp-auth-password="xxxx"
    set smtp-auth=login
    

    参考

    Linux发邮件-ubuntu和centos
    http://yiilib.com/en/topic/731/Centos+use+Mailx+send+SMTP+Mail

    相关文章

      网友评论

          本文标题:Linux 配置sendmail发送邮件

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