第一步:移植msmtp
下载地址:http://download.chinaunix.net/download.php?id=44453&ResourceID=7048
下载后的名称为:msmtp-1.4.30.tar.bz2
解压缩编译:
./configure --host=arm CC=arm-linux-gcc --prefix=/work/msmtp-1.4.30/target
make
make install
将在target/bin中生成文件:msmtp,将其拷贝到板子上。
新建配置文件:/usr/local/etc/msmtprc内容如下:
host smtp.163.com
port 25
from coobutter@163.com
auth login
tls off
user coobutter@163.com
password ******(此为邮箱的密码)
logfile /var/log/msmtp.log
执行命令:msmtp–t
然后输入:
from:coobutter@163.com
to:754237823@qq.com
subject:msmtptest
hello this is coobutter!(此行为文本内容,此行之前必须要有空行)
然后按下ctrl+D,
发送完毕,到qq邮箱检查收到的邮件,
第二步、移植mutt
下载地址:http://www.mutt.org/download.html
下载后的名称为:mutt-1.5.21.tar.gz
解压缩,配置:./configure --host=arm-linux --enable-pop CC=arm-linux-gcc
修改mutt-1.5.21/doc/Makefile,将 CC修改为宿主机下的gcc
编译:make,
编译完成之后,将会在mutt-1.5.21下生成mutt,将mutt拷贝到板子上
在板子上建立配置文件
将上一步生成的msmtp拷贝到/usr/bin中
在目录/usr/local/etc中建立配置文件Muttrc,内容如下:
set sendmail="/usr/bin/msmtp"
set use_from=yes
set realname=coobutter@163.com
set from= coobutter@163.com
set editor="vi"
发送邮件测试:
./mutt -s "linkmail" rkernel@live.cn -a /root/test.bmp </root/mailtest.txt
-s 参数后是发送邮件的“标题”和“收件人”
-a 参数后是“附件”的路径
< /root/mail.txt 是邮件的文被内容,mail.txt里面的内容为“this is text file!”
第三步、发送测试
发送附件/root/test.bmp,文本内容为/root/mailtest.txt
mutt -s "linkmail" 754237823@qq.com -a /root/test.bmp < /root/mailtest.txt
只发送文本
mutt -s "linkmail" 754237823@qq.com < /root/mailtest.txt
或者
echo "hello this echo print"|mutt -s "linkmail" 754237823@qq.com
发送多个附件
mutt -s "linkmail" 754237823@qq.com -a /root/test1.txt -a /root/test2.txt </root/mailtest.txt
多个收件人
mutt -s "linkmail" 754237823@qq.com rkernel@live.cn -a /root/test1.txt < /root/mailtest.txt
多个收件人多个附件
mutt -s "linkmail" 754237823@qq.com rkernel@live.cn -a/root/test1.txt -a /root/test2.txt < /root/mailtest.txt