实例:
$content ="ceshi";
$technicalemail="chenlong@anheng.com.cn";
$headers = "From: =?utf-8?B?".base64_encode('chenglong')."?= <$technicalemail>\r\n";
$content = strip_tags($content);
$a = @mail($technicalemail,'=?utf-8?B?'.base64_encode('出错提交').'?=',$content,$headers);
if($a)
{
echo '邮件发送成功!';
}
通过mail()函数发送:
1,需要配置php.ini邮件信息
打开php.ini配置文件,配置红色的位置
; For Win32 only.
SMTP = localhost ---如果本机装了sendmail,这个表示使用本地邮件服务器,也可以是ip地址,还有服务器域名
smtp_port = 25 ---端口号
; For Win32 only.
;sendmail_from = me@example.com ---可写可不写 把这里的分号去掉
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path = ----邮件服务器的路径
2.mail()函数
mail()函数允许从脚本直接发送电子邮件
mail()函数返回的是boolean值,成功返回true,失败返回flase
mail(to,subject,message,headers,paeameters);
to --必需,规定邮件的接收者
subject --必需,规定邮件的主题,该参数不能包含任何换行字符
message --必需,规定要发送的消息
headers --可选,规定额外的报头,比如from,Cc以及Bcc 可以参考一些资料
parameters --可选,规定sendmail程序的额外参数