Linux 邮件

Msmtp官网

https://marlam.de/msmtp/
Msmtp下载地址:https://marlam.de/msmtp/download/

Msmtp的下载安装

1、下载源码解压并编译

  1. wget https://marlam.de/msmtp/releases/msmtp-1.8.12.tar.xz
  2. xz -d msmtp-1.8.12.tar.xz
  3. tar -xf msmtp-1.8.12.tar
  4. cd msmtp-1.8.12
  5. ./configure --prefix=/usr/local/msmtp
  6. make && make install

2、创建msmtp配置文件和日志文件(host为邮件域名,邮件用户名test,密码123456)

  1. $ vim ~/.msmtprc
  2. account default
  3. host 126.com
  4. from test@126.com
  5. auth login
  6. user test
  7. password 123456
  8. logfile ~/.msmtp.log
  9. $ chmod 600 ~/.msmtprc
  10. $ touch ~/.msmtp.log

3、mutt安装配置:(一般linux下有默认安装mutt)

  1. $ yum install mutt
  2. $ vim ~/.muttrc
  3. set sendmail="/usr/local/msmtp/bin/msmtp"
  4. set use_from=yes
  5. set realname="memory"
  6. set from=test@126.com
  7. set envelope_from=yes
  8. set rfc2047_parameters=yes
  9. set charset="utf-8"

测试邮件发送

  1. echo "邮件内容123456" | mutt -s "邮件标题测试邮件" -a /scripts/test.txt test@126.com