加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php发送邮件函数mail 教程

发布时间:2020-12-13 20:53:48 所属栏目:PHP教程 来源:网络整理
导读:好了下面我们来看看php发送邮件函数mail 教程,如果要使用mail函数能够正常使用我们还得配置php.ini里面的参数哦. ?php //定义边界线 $boundary =uniqid( ); //生成邮件头 $header =From: $fromnContent -type:multipart/mixed; boundary= $boundary nX-Maile

好了下面我们来看看php发送邮件函数mail 教程,如果要使用mail函数能够正常使用我们还得配置php.ini里面的参数哦.

  1. <?php 
  2. //定义边界线 
  3. $boundary = uniqid( "" );  
  4. //生成邮件头 
  5. $header = "From: $fromnContent-type: multipart/mixed; 
  6. boundary="$boundary"nX-Mailer:PHPnX-Priority:3"; 
  7. //获取附件文件的MIME类型  
  8. $mimetype = mime_content_type('test.zip'
  9. //获取附件文件的名字  
  10. $attach = 'test.zip' 
  11. //对附件文件进行编码和切分 
  12. $fp = fopen($attach"r"); 
  13. $content = fread($fpfilesize($attach)); 
  14. $content = chunk_splitbase64_encode($content) ); 
  15. //生成邮件主体  
  16. $body =" 
  17. --$boundary 
  18. Content-type: text/plain; charset=iso-8859-1 
  19. Content-transfer-encoding: 8bit 
  20. $message 
  21. --$boundary 
  22. Content-Type: $mimeType; name=$filename 
  23. Content-Disposition: attachment; filename=$filename 
  24. Content-Transfer-Encoding: base64 
  25. $content 
  26. --$boundary--"; 
  27. //发送邮件 
  28. mail( $to$subject$body$header ); 
  29. ?> 

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读