ubuntu 18.04上使用sendemail命令行发送邮件。

版权声明:本文为CSDN博主「warlice」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/warlice/article/details/90519232

1. 在ubuntu上安装sendemail。

apt install sendemail

 

2. 查看sendemail的帮助

我只把常用的参数发出来。

sendEmail --help

sendEmail-1.56 by Brandon Zehm <caspian@dotconf.net>

Synopsis:  sendEmail -f ADDRESS [options]

  Required:
    -f ADDRESS                from (sender) email address
    * At least one recipient required via -t, -cc, or -bcc
    * Message body required via -m, STDIN, or -o message-file=FILE

  Common:
    -t ADDRESS [ADDR ...]     to email address(es)
    -u SUBJECT                message subject
    -m MESSAGE                message body
    -s SERVER[:PORT]          smtp mail relay, default is localhost:25
    -S [SENDMAIL_PATH]        use local sendmail utility (default: /usr/bin/sendmail) instead of network MTA

  Optional:
    -a   FILE [FILE ...]      file attachment(s)
    -cc  ADDRESS [ADDR ...]   cc  email address(es)
    -bcc ADDRESS [ADDR ...]   bcc email address(es)
    -xu  USERNAME             username for SMTP authentication
    -xp  PASSWORD             password for SMTP authentication

 

3. 获取邮箱的smtp验证码

我使用的是qq邮箱。,在设置/账户页,查找到如下设置。点击开启pop3/smtp服务。这个过程需要用安保手机向服务方发送“配置邮件客户端”的短信。然后你就可以看到你的授权码了。

 

4. 使用sendEmail命令发送邮件

注意:不要使用sendemail命令,这个是局域网内部发送使用的。

sendEmail  -xu 11989686@qq.com -xp pkjdfgaesozomkkhde -t 11989686@qq.com -u "这是标题" -m "这是正文" -s smtp.qq.com  -f 11989686@qq.com

-t 是接受邮箱地址

-f 是发送邮箱地址

-xu 是smtp邮箱用户名

-xp 是smtp的授权码

-u 是主题

-m 是邮件正文

-s 是smtp服务器域名

常用邮箱SMTP服务器地址大全

原文地址:https://blog.csdn.net/Gents_hu/article/details/92219811

  阿里云邮箱(mail.aliyun.com):

  POP3服务器地址:pop3.aliyun.com(SSL加密端口:995;非加密端口:110)

  SMTP服务器地址:smtp.aliyun.com(SSL加密端口:465;非加密端口:25)

  IMAP服务器地址:imap.aliyun.com(SSL加密端口:993;非加密端口:143)

  

  谷歌邮箱(google.com):

  POP3服务器地址:pop.gmail.com(SSL启用端口:995)

  SMTP服务器地址:smtp.gmail.com(SSL启用端口:587)

  

  新浪邮箱(sina.com):

  POP3服务器地址:pop3.sina.com.cn(端口:110)

  SMTP服务器地址:smtp.sina.com.cn(端口:25)

  

  Tom邮箱(top.com):

  POP3服务器地址:pop.tom.com(端口:110)

  SMTP服务器地址:smtp.tom.com(端口:25)

  

  网易邮箱(163.com):

  POP3服务器地址:pop.163.com(端口:110)

  SMTP服务器地址:smtp.163.com(端口:25)

  

  126邮箱:

  POP3服务器地址:pop.live.com(端口:995)

  SMTP服务器地址:smtp.126.com(端口:25)

  

  雅虎邮箱(yahoo.com):

  POP3服务器地址:pop.mail.yahoo.com

  SMTP服务器地址:smtp.mail.yahoo.com

  

  雅虎中国(yahoo.com.cn):

  POP3服务器地址:pop.mail.yahoo.com.cn(端口:995)

  SMTP服务器地址:smtp.mail.yahoo.com.cn(端口:587)

  雅虎邮箱POP3的SSL不启用端口为110,POP3的SSL启用端口995;SMTP的SSL不启用端口为25,SMTP的SSL启用端口为465。

  

  Foxmail邮箱(foxmail.com):

  POP3服务器地址:POP.foxmail.com(端口:110)

  SMTP服务器地址:SMTP.foxmail.com(端口:25)

  

  QQ邮箱(mail.qq.com)

  POP3服务器地址:pop.qq.com(端口:110)

  SMTP服务器地址:smtp.qq.com(端口:25)

  SMTP服务器需要身份验证。

  

  搜狐邮箱(sohu.com):

  POP3服务器地址:pop3.sohu.com(端口:110)

  SMTP服务器地址:smtp.sohu.com(端口:25)

  

  HotMail邮箱(hotmail.com):

  POP3服务器地址:pop.live.com(端口:995)

  SMTP服务器地址:smtp.live.com(端口:587

  

  移动139邮箱:

  POP3服务器地址:POP.139.com(端口:110)

  SMTP服务器地址:SMTP.139.com(端口:25)

  

  中华网邮箱(china.com):

  POP3服务器地址:pop.china.com(端口:110)

  SMTP服务器地址:smtp.china.com(端口:25)

posted @ 2019-12-09 18:39  逐梦客!  阅读(1075)  评论(0)    收藏  举报