参考:https://blog.csdn.net/farsight2009/article/details/5545156
资源ssmtp_2.64.orig.tar.bz2与mailx-12.4.tar.bz2
ssmtp_2.64.orig.tar.bz2
解压后配置,make;make install 可以得到ssmtp,及/etc/ssmtp/下revaliases ssmtp.conf两个文件
CC=arm-hisiv400-linux-gcc;./configure --host=arm-hisiv400-linux --prefix=../build--sysconfdir=/etc --no-recursion --enable-ssl
sed -i "s/$(INSTALL) -s -m/$(INSTALL) -m/g" ./Makefile #安装时install -s指令屏蔽,可以不理会,
--enable-ssl,我暂时没有添加这个选项,仅能使用smtp协议的25端口号。
mailx-12.4.tar.bz2
解压后进入路径,使用如下指令编译
CC=arm-hisiv400-linux-gcc make
部署
1.拷贝ssmtp 到板子的/usr/sbin/目录
2.在/usr/lib/路径下建立sendmail 指向ssmtp的软连接 路径不能错
ln -s /usr/sbin/ssmtp /usr/lib/sendmail
3.拷贝mailx到/usr/sbin下
4.在/usr/sbin下建立mail到mailx的软连接
ln -s /usr/sbin/mailx /usr/sbin/mail
5.拷贝编编译ssmtp生成的配置目录到板子的/etc/ssmtp的目录下保证/etc/ssmtp目录下有如下两个文件
revaliases ssmtp.conf
6.修改/etc/ssmtp/配置文件
revaliases文件添加最后一行
# sSMTP aliases
#
# Format: local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
root:xxx@xxx.com.cn:smtp.xxx.com.cn:25
ssmtp.conf
#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=yourmailaddr@xxx.com.cn
# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and you mailhub is so named.
mailhub=smtp.xxx.com.cn:25
# Where will the mail seem to come from?
#rewriteDomain=xxx
# The full hostname
hostname=xxx-System-Product-Namei
AuthUser=xxx@xxx.com.cn
AuthPass=xxxxxxxx
测试指令
echo "aaa" | mail -v -a ./xx.tar.gz -s "test" xxxxxx@yeah.net
echo是邮件内容,-v是显示邮件过程细节,-a后边是附件,-s是标题 ,最后的是目的邮箱