CentOS配置smtp发邮件

修改/etc/mail.rc文件,在最后一行加入以下内容

set from=fromUser@donai.com               #发送的邮件地址(发件人)
set smtp=smtp.domain.comset               #smtp服务器地址
set smtp-auth-user=username               #邮箱用户名
set smtp-auth-password=password           #邮箱密码
set smtp-auth=login                       #邮箱认证方式

举例

set from=zhangsan@163.com smtp=smtp.163.com
set smtp-auth-user=zhangsan smtp-auth-password=Passwd smtp-auth=login

发邮件邮件

mail -s "hosts" 628905@qq.com < /etc/hosts

# -s 指定邮件主题 hosts
# 收件人 628905@qq.com
# 邮件内容为/etc/hosts内的内容
原文地址:https://www.cnblogs.com/Liangdalong/p/5844213.html