使用mail.rc快速配置linux发邮件服务推荐

1.系统环境。

[root@web02~]#cat/etc/redhat-releaseCentOSrelease6.8(Final)[root@web02~]#uname-r2.6.32-642.el6.x86_64[root@web02~]#uname-mx86_64

2.通过修改配置文件/etc/mail.rc可以使用外部SMTP服务器,轻松实现linux发邮件功能。

[root@web02~]#tail/etc/mail.rc#ForLinuxandBSD,thisshouldbeset.setbsdcompat#sendmailconfigsetfrom=user@foxmail.comsetsmtp=smtp.qq.comsetsmtp-auth-user=user@foxmail.comsetsmtp-auth-password=xxxxxxxxxxxxxxxsetsmtp-auth=login

注意:目前大部分的外部邮件服务使用第三方客户端时,都需要使用授权码,上面的smtp-auth-password使用的就是授权码,而不是邮件帐号的密码。

3.相关命令和选项的作用。

-s 邮件主题 :指定邮件的主题;-c 地址 :添加邮件抄送人,多个人时用逗号隔开;-b 地址 :添加邮件暗送人;-a 附件 :添加附件Attachthegivenfiletothemessage.

(1)方法一:正文内容重定向输入。

[root@web02~]#mail-s"标题"-a/etc/hosts-cuser1@163.com,user2@163.comuser@foxmail.com /etc/hosts#当主送和抄送有多个人时,请使用逗号隔开。

(2)方法二:正文内容通过echo命令输入。

[root@web02~]#echo"正文"|mail-s"标题"-a/etc/hosts-cuser1@163.com,user2@163.comuser@foxmail.com

4.启动postfix服务

[root@web02~]#/etc/init.d/postfixstartStartingpostfix:[OK][root@mysql01~]#chkconfig--level3postfixon[root@mysql01~]#chkconfig|greppostfixpostfix0:off1:off2:off3:on4:off5:off6:off

到此为止,发邮件配置完毕。可以正常测试。

是清晰的又是朦胧的,是一杯苦茶,最后却品出清雅之香。

使用mail.rc快速配置linux发邮件服务推荐

相关文章:

你感兴趣的文章:

标签云: