PHP的mail函数
// 发送邮件
function send($mails){
$to = 'a@a.com, b@b.com';
$title = '检查结果';
$content = "以下订单号有错误" . "\r\n";
$content .= "id:1,2,3";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=utf-8" . "\r\n";
$headers .= "From: system@system.com"; // 自定义
$r = mail($to, $title, $content, $headers);
var_dump($r);
}
注意的问题
- 标题做编码处理(不同客户端的编码不同,可能会乱码)
$subject = iconv('','GB2312','亲爱的'.$s_user.',请取回您的密码!');
Linux
环境
·linux·下注意·/usr/sbin/sendmail· 或者·/usr/bin/sendmail·是否存在
若不存在可能是没安装
sudo apt-get install sendmail
然后就可以直接用 PHP
内置的mail()
函数了
php.ini
配置
[mail function]
; For Win32 only.
SMTP = smtp.126.com
#smtp_port = 25
; For Win32 only.
sendmail_from = jiangwei8909@126.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i ").
;sendmail_path =
前三项对windows
环境生效 sendmail_path
对unix
生效
- 上一篇: PHP执行时间类
- 下一篇: js判断页面是否有滚动条