配置mutt自动发邮件

环境:cygwin

1) install
apt-cyg install msmtp
apt-cyg install mutt

注:apt-cyg是cygwin下类似apt-get的小脚本,google可搜到。

2) msmtp-config
host: mail.auto.com.cn
from: [email protected]
auth: login
user: [email protected]
password: ××××
注意:

狗日的msmtp-config把配置文件放在/etc/msmtp/msmtprc,配置之后用不了,急得人跳墙;
无意间 msmtp –version 看到:
System configuration file name: /etc/msmtprc
把msmtprc从/etc/msmtp/下挪到/etc/, 所有问题解决, Cao!
测试:echo “test msmtp” | msmtp [email protected]

3) config mutt
mkdir ~/.mutt
vi muttrc:
set sendmail=”/usr/sbin/msmtp”
set [email protected]

测试:echo “内容……” | mutt -s “subject……” [email protected]

4) 提示
可以自己编辑个 mail.sh 或者 mail.bat 方便地进行文件发送。
如果给gmail邮箱发,有些exe或者bat文件gmail不接受。

例子:

#!/usr/bin/sh
if [ $# -eq 0 ]
then
    echo "send file to gmail"
    echo usage:
    echo "    mail.sh file [target@address]"
elif [ $# -eq 1 ]
then
    echo mutt -s "$1" -a "$1" [email protected]
    echo "$1" | mutt -s "$1" -a "$1" [email protected]
elif [ $# -eq 2 ]   
then
    echo mutt -s "$1" -a "$1" $2
    echo "$1" | mutt -s "$1" -a "$1" $2
fi

猜你喜欢

转载自jamesqiu.iteye.com/blog/456620
今日推荐