Ubuntu 安装工具
apt-get install heirloom-mailx
修改配置
vim /etc/s-nail.rc
在文件最后加入如下配置项:
set from="mailtest@3vyd.com"
set smtp="smtp.exmail.qq.com"
set smtp-auth-user="mailtest@3vyd.com"
set smtp-auth-password="xxxx"
set smtp-auth=login
测试邮件
echo "测试的邮件内容" | s-nail -s "测试的邮件主题" marvin.ma@redcreation.net
mail
注意
root@hk-server:~# Could not connect: Operation now in progress
“/root/dead.letter” 8/209
… message not sent
这里注意!因为是阿里云服务器,可能是25端口被封,得改用465端口,所以配置内容那里要注意将smtp配置加上端口:
set smtp=smtp.exmail.qq.com:465
centos
- install Mailx
yum install -y mailx
- Config SMTP Params
vi /etc/mail.rc
# Add Gmail SMTP
set from=yiilib.com_t@gmail.com #send from mail address
set smtp=smtp.gmail.com #SMTP server domain
set smtp-auth-user=yiilib.com_t #send account
set smtp-auth-password=mailBoxPassword #account password
set smtp-auth=login #auth way
- send test
echo "mail body" | mail marvin.ma@redcreation.net -s "test mail subject" -a /root/backup/yiilib.com_tmp.sql
两种常用配置
- 腾讯企业邮箱
set from="mailtest@3vyd.com"
set smtp="smtp.exmail.qq.com"
set smtp-auth-user="mailtest@3vyd.com"
set smtp-auth-password="xxxx"
set smtp-auth=login
- 163网易邮箱(密码是指客户端授权密码)
set from="chuangkehui@163.com"
set smtp="smtp.163.com"
set smtp-auth-user="chuangkehui@163.com"
set smtp-auth-password="xxxx"
set smtp-auth=login
参考
Linux发邮件-ubuntu和centos
http://yiilib.com/en/topic/731/Centos+use+Mailx+send+SMTP+Mail
网友评论