CentOS
- stop or remove sendmail:yum remove sendmail
- yum install postfix
- yum install mailx
-
检查MTA是否为Postfix:alternatives --display mta
- 如果不是更改默认MTA为Postfix:/usr/sbin/alternatives --set mta /usr/sbin/sendmail.postfix
- 检测并启动Postfix
-
service postfix status
-
service postfix start
-
- 设置开机启动 chkconfig postfix on
/etc/mail.rc
配置mail
set from=test@163.com
set smtp=smtp.163.com
set smtp-auth-user=test
set smtp-auth-password=test
set smtp-auth=login
set smtp=smtp.163.com
set smtp-auth-user=test
set smtp-auth-password=test
set smtp-auth=login
OSX
使用sendemail
发送邮件:
最简单的方法:
mail -s text **@mail.ustc.edu.cn
这条命令的结果是发一封标题为text的空信给后面的邮箱,但是往往这类邮件会被当成垃圾邮件来处理,所以如果没有收到邮件,建议打开垃圾箱来查看一下.第一种方法,你可以把当前shell当成编辑器来用,编辑完内容后Ctrl-D结束。
#第二种方法,使用管道命令
echo “This is a test mail!”|mail -s text **@mail.ustc.edu.cn
#第三种方法,使用重定向。
mail -s test **@mail.ustc.edu.cn < file
以file的内容为邮件内容发信,首先选择事先写好一个文档然后再mail过去。
带附件的邮件发送(重点)
如果你的系统中没有uuencode命令的话,则需要先安装sharutils,
sudo apt-get install sharutils。
uuencode 需要两个参数,第一个是你要发送的文件,当然这个也可以用管道来做,第二个是显示的文件名
uuencode /home/daniel/httpd.conf httpd.conf|mail -s mailtest **@mail.ustc.edu.cn