Linux 配置sendmail发送邮件

2020-04-18  本文已影响0人  小马将过河

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

  1. install Mailx
yum install -y mailx
 
  1. 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
 
  1. 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
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

上一篇下一篇

猜你喜欢

热点阅读