红联Linux门户
Linux帮助

在RHEL6中使用mail命令发外部邮件

发布时间:2014-06-28 10:29:31来源:红联作者:velcbo
首先,卸载掉系统自带的sendmail和postfix:

yum remove sendmail

yum remove postfix

然后在/etc/mail.rc中添加下面几行:

set from=123456@126.com

set smtp=smtp.126.com

set smtp-auth-user=123456

set smtp-auth-password=xxxxxxx

set smtp-auth=login

说明:from是指发件人,smtp-auth-user和smtp-auth-password是指用户名和密码,smtp-auth配置为登录方式。

接下来就是使用mail命令来发邮件了,执行下面的命令:

echo "Content Hello" | mail -s "Test Title" -a testfile.txt 123456@qq.com

说明:echo的内容为邮件正文,-s是指邮件标题,-a是指附件,最后的123456@qq.com是指收件人。

更多用法请参考mail的man手册。

作者:yuanhuan
文章评论

共有 0 条评论