mailx安装
1、手动安装:
wget http://ftp.debian.org/debian/pool/main/h/heirloom-mailx/heirloom-mailx_12.5.orig.tar.gz
tar zxvf heirloom-mailx_12.5.orig.tar.gz
cd heirloom-mailx-12.5/
make && make install UCBINSTALL=/usr/bin/install
vi /etc/nail.rc(在配置文件最后添加)
set from=mail.aliyun.com #(需修改)收件人显示的发件人名称,可填写你的名字等
set smtp=smtp.aliyun.com (需修改)你所使用的外部邮箱的smtp服务器地址
set smtp-auth-user=mag00g@aliyun.com (需修改)你所使用的外部邮箱的用户名
set smtp-auth-password=1980019Ss (需修改)你所使用的外部邮箱密码
set smtp-auth=login
测试
echo 123 | mailx -v -s "test" 7710xxxx1@aliyun.com
2、自动安装
$ sudo apt-get install heirloom-mailx
文件内容发送
mail -s "主题" 收件地址 < 文件路径文件名
mail -s "test" xxx@xxx.com < ./xxx/xxx.txt
cat 邮件正文.txt | mail -s 邮件主题 xxx@xxx.com
单内容发送
echo "邮件正文内容" | mail -s "邮件主题" xxx@xxx.com
带附件
注意-a的位置放置有讲究。
mail -a 附件 -s "主题" 收件地址 < 文件(邮件正文.txt)
mail -a test.cpp -s " mail test" xxx@aliyun.com < test.cpp