参考自:http://blog.csdn.net/shiningstarpxx/article/details/41008325
http://blog.sina.com.cn/s/blog_65c89dad01015r29.html
1、安装sendmail
yum -y install sendmail
2.安装mail命令
yum -y install mailx
3.开启sendmail
/etc/rc.d/init.d/sendmail start
4.设置开机启动
vim /etc/rc.local
最后一行添加上:
/etc/rc.d/init.d/sendmail start
安装成功
可以直接使用:
echo "This is test mail" | mail -s 'Test mail' your@mail.com 进行测试
$to = 'xxxx@qq.com' // 发送人 $cc = 'xxxx@163.com'; // 转呈人 $from = 'smtp.qq.com'; // 发送人 $title = 'test title'; // 标题 $content = 'test content'; // 内容 // 当发送 HTML 电子邮件时,请始终设置 content-type $headers = "MIME-Version: 1.0" . " "; $headers .= "Content-type:text/html;charset=utf-8" . " "; // 更多报头 $headers .= 'From: '.$from . " "; $headers .= "Cc: ".$cc . " "; $result = mail($to_mail,$title,$content,$headers);
如果发送缓慢:参考我的另一篇文章:
另附php mail 函数用法
mail(“165482921@qq.com“,”邮件主题”,”正文内容”,”from:xxxx@163.com”);