linux 配置外部邮箱发送邮件

下载mailx包mailx官方站点 http://heirloom.sourceforge.net/

[root@localhost ~]# wget http://sourceforge.net/projects/heirloom/files/latest/download?source=files

linux 配置外部邮箱发送邮件

[root@localhost ~]# mv download\?source\=files mailx-12.4.tar.bz2
[root@localhost ~]# tar xf mailx-12.4.tar.bz2
[root@localhost ~]# cd mailx-12.4

打个补丁才可以用:

linux 配置外部邮箱发送邮件

本站下载:
[root@localhost mailx-12.4]# wget https://www.jinchuang.org/novel/lnmp/mailx-12.4-openssl_1.0.0_build_fix-1.patch

[root@localhost mailx-12.4]# patch -Np1 -i mailx-12.4-openssl_1.0.0_build_fix-1.patch
patching file makeconfig
patching file openssl.c
[root@localhost mailx-12.4]# make
[root@localhost mailx-12.4]# make install UCBINSTALL=/usr/bin/install

下面为输出信息:

linux 配置外部邮箱发送邮件

test -d /usr/local/bin || mkdir -p /usr/local/bin
/usr/bin/install -c mailx /usr/local/bin/mailx
strip /usr/local/bin/mailx
test -d /usr/local/share/man/man1 || mkdir -p /usr/local/share/man/man1
/usr/bin/install -c -m 644 mailx.1 /usr/local/share/man/man1/mailx.1
test -d /etc || mkdir -p /etc
test -f /etc/nail.rc || \
		/usr/bin/install -c -m 644 nail.rc /etc/nail.rc


[root@localhost mailx-12.4]# vim /etc/nail.rc
编辑配置文件最下面加上:修改为你自己的
set from=xxx@163.com smtp=smtp.163.com
set smtp-auth-user=xxx@163.com smtp-auth-password=邮箱密码
set smtp-auth=login

[root@localhost mailx-12.4]# which mailx
/usr/local/bin/mailx
[root@localhost mailx-12.4]# cd /bin
[root@localhost bin]# ln -s /usr/local/bin/mailx mail
[root@localhost bin]# mail -V
12.4 7/29/08
[root@localhost bin]# mail -s "Message"  jinchuang1025@163.com < /tmp/yum_save_tx-2016-11-10-17-274YsBZQ.yumtx 
[root@localhost bin]# echo $?
0

发送结果:

linux 配置外部邮箱发送邮件

分享