使用sendmail发邮件的配置html
yum -y install sendmail
service sendmail startlinux
vim body.txt
test mail from linux.vim
mail -s "test mail from linux" yourname@163.com,yourname2@163.com <body.txtcentos
mailq #查看邮件队列
cat /var/log/maillogbash
【注意:】 多个邮件地址以西文,分割;测试
配置邮件发送显示帐号ui
vim + /etc/mail.rc # For Linux and BSD, this should be set. set bsdcompat set from=devops #把devops换成本身想显示的名称
------------------------------------------------------------this
邮件相关配置的文件spa
/etc/aliases.net
------------------------------------------------------------
如使用外部邮箱smtp方式发邮件,设置smtp的验证规则配置,同时,在network中配hostname定义,sendmail发邮件只识别hostname.
配置时from和=间不要有空格,否则提示“ Non-null variable name required”。
vim /etc/mail.rc
set from=yourname@163.com smtp=smtp.163.com
set smtp-auth-user=yourname@163.com smtp-auth-password=yourpassword smtp-auth=login
vim /etc/sysconfig/network
hostname mail.163.com
---------------------------------
【测试过程问题记录】
一、163的邮箱开启smtp服务时必须设置受权码,在/etc/mail.rc smtp-auth-password设置成受权码,否则错给你看
smtp-server: 535 Error: authentication failed
二、163邮箱不开启smtp服务,换个错误给你看
smtp-server: 550 User has no permission
三、安装后遇到 以下错误则安装mailx
-bash: mail: command not found
yum install mailx
[root@localhost logs]# mailx -s "testilink" linjin200@163.com </data/aa.txt
【总结】
用smtp发个邮件好纠结,各路神仙都要照顾到,否则哪哪都要罢个工。