知识屋:更实用的电脑技术知识网站
所在位置:首页 > 编程技术 > PHP编程

php发送邮件(方法一)

发布时间:2015-05-27 19:34:01作者:知识屋

[html] 
1. <span style="font-size:18px;">实例:</span>    
[html] 
1.        $content       ="ceshi"; 
2.        $technicalemail="www.zhishiwu.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.zhishiwu.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

(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜