centos 7的邮件发送

1配置文件vim /etc/mail.rc

	vim /etc/mail.rc 
  • 翻到文件尾部添加

    set from=xx@163.com smtp=smtp.163.com smtp-auth-user=xx smtp-auth-password=授权码 smtp-auth=login

set from=(y1134634181@163.com #163邮箱) smtp=smtp(.163.com #邮箱后缀) smtp-auth-user=(y1134634181# 用户名) smtp-auth-password=(客户端的授权码)smtp-auth=login

  • 注:格式必须书写规范、正确。

2启动邮件服务

    # systemctl status postfix.service        #查看邮件服务状态
    ● postfix.service - Postfix Mail Transport Agent
       Loaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor preset: disabled)
       Active: inactive (dead)              #关闭状态
    # systemctl start postfix.service      #开启邮件服务
    # systemctl status postfix.service     #再次查看状态
    ● postfix.service - Postfix Mail Transport Agent
       Loaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor preset: disabled)
       Active: active (running) since 二 2019-04-16 16:44:13 CST; 1s ago      #running表示服务运行中 ,服务已开启
      Process: 24088 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)        
      Process: 24085 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
      Process: 24083 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
     Main PID: 24160 (master)
       CGroup: /system.slice/postfix.service
       ├─24160 /usr/libexec/postfix/master -w
       ├─24162 pickup -l -t unix -u
       └─24163 qmgr -l -t unix -u

3发送邮件

  • 邮件发送为转发格式,也就是说我们发送的文件通过我们配置的@163邮箱转发到我们的QQ邮箱

    格式
    mail -s "linux"  xxxxxxx@qq.com
    mailq    #查看发送邮件的状态
  • mail -s(参数) “linux(#邮件标题 )” xxxxxxx@qq.com (QQ邮箱)

  • 以“linux”为标题,内容为“woshilaoda”,发送邮件到我的QQ邮箱

    echo "woshilaoda" |mail -s "linux"   xxxxxxxx@qq.com 

注:发送的邮件可能会因为网络问题而延迟到达邮箱,请耐心等待

版权声明:本文为jiangyatao原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/jiangyatao/p/10719620.html