当前位置:Gxlcms > PHP教程 > php发送邮件(方法一)_PHP教程

php发送邮件(方法一)_PHP教程

时间:2021-07-01 10:21:17 帮助过:5人阅读

[html]
1. 实例:
[html]
1. $content ="ceshi";
2. $technicalemail="www.2cto.com";
3. $headers = "From: =?utf-8?B?".base64_encode('chenglong')."?= <$technicalemail>\r\n";
4.
5. $content = strip_tags($content);
6. $a = @mail($technicalemail,'=?utf-8?B?'.base64_encode('出错提交').'?=',$content,$headers);
7. if($a)
8. {
9. echo '邮件发送成功!';
10. }
通过mail()函数发送:
1,需要配置php.ini邮件信息
打开php.ini配置文件,配置红色的位置
; For Win32 only.
SMTP = localhost ---如果本机装了sendmail,这个表示使用本地邮件服务器,也可以是ip地址,还有服务器域名
smtp_port = 25 ---端口号
; For Win32 only.
;sendmail_from = www.2cto.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程序的额外参数
3. php.ini 中 将extension=php_imap.dll前面的“;”去掉

作者:Vericlongmore

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478152.htmlTechArticle[html] 1.span style=font-size:18px;实例:/span [html] 1. $content =ceshi; 2. $technicalemail=www.2cto.com; 3.$headers = From: =?utf-8?B?.base64_encode(chenglong).?= $technicalemai...

人气教程排行