欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

mail、sendEmail发送邮件命令

发布时间:2025/3/15 编程问答 33 豆豆
生活随笔 收集整理的这篇文章主要介绍了 mail、sendEmail发送邮件命令 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

申请临时邮箱地址

  • https://blog.csdn.net/u012206617/article/details/104632026

 

Centos

centos自带mail工具

安装mail

  • yum -y install mailx

配置发送人帐号信息

  • vim /etc/mail.rc
  • 在最后加两行代码
    • set from=123456@163.com smtp=smtp.163.com
    • set smtp-auth-user=123456@163.com smtp-auth-password=666666 smtp-auth=login

 

Ubuntu

安装mail

  • apt-get install heirloom-mailx

配置发送人账户信息

  • vim /etc/s-nail.rc 或 /nail.rc(本人是/etc/s-nail.rc)
  • 在最后增加两行代码
    • set from=123456@163.com smtp=smtp.163.com
    • set smtp-auth-user=123456@163.com smtp-auth-password=666666 smtp-auth=login

 

mail工具使用

读取文件内容发送

  • mail -s "主题" 邮箱地址 < path/filename

管道形式发送

  • echo "邮件内容" | mail -s "主题" 邮箱地址

给多个用户发送邮件

  • mail -s test -c admin@aispider.com  root@aispider.com< file

发送附件邮件

  • yum install sharutils 或 apt-get install sharutils
  • uuencode /home/zhousir/httpd.conf httpd.conf|mail -s mailtest 123@qq.com
  • tar czf - /home/zhousir/ | uuencode home.tgz |mail -s mailtest 123@qq.com
  • uuencode test.txt test | mail -s "hello,see the attachement" 123@qq.com < mail.txt 

 

sendEmail工具使用

安装

  • apt-get install sendemail 

发送内容

  • sendEmail -f 123@163.com -t 123@qq.com -s smtp.163.com -u "主题测试" -o message-content-type=html -o message-charset=utf-8 -o tls=no -xu 123@163.com -xp 123 -m "邮件内容"

发送多人

  • sendEmail -f 123@163.com -t 123@qq.com 456@qq.com -s smtp.163.com -u "主题测试" -o message-content-type=html -o message-charset=utf-8 -o tls=no -xu 123@163.com -xp 123 -m "邮件内容"

发送抄送人

  • sendEmail -f 123@163.com -t 123@qq.com -cc 456@qq.com -s smtp.163.com -u "主题测试" -o message-content-type=html -o message-charset=utf-8 -o tls=no -xu 123@163.com -xp 123 -m "邮件内容"

发送附件

  • sendEmail -f 123@163.com -t 123@qq.com -s smtp.163.com -u "主题测试" -o message-content-type=html -o message-charset=utf-8 -o tls=no -xu 123@163.com -xp 123 -m "邮件内容" -a ./abc.txt
新人创作打卡挑战赛发博客就能抽奖!定制产品红包拿不停!

总结

以上是生活随笔为你收集整理的mail、sendEmail发送邮件命令的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。