Home >php教程 >php手册 >php发送邮件函数mail 教程

php发送邮件函数mail 教程

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-25 16:49:34971browse

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

<?php 
	//定义边界线 
	$boundary = uniqid( "" );  
	//生成邮件头 
	$header = "From: $fromnContent-type: multipart/mixed; 
	boundary="$boundary"nX-Mailer:PHPnX-Priority:3"; 
	//获取附件文件的MIME类型  
	$mimetype = mime_content_type(&#39;test.zip&#39;) 
	//获取附件文件的名字  
	$attach = &#39;test.zip&#39; 
	//对附件文件进行编码和切分 
	$fp = fopen($attach, "r"); 
	$content = fread($fp, filesize($attach)); 
	$content = chunk_split( base64_encode($content) ); 
	//生成邮件主体  
	$body =" 
	--$boundary 
	Content-type: text/plain; charset=iso-8859-1 
	Content-transfer-encoding: 8bit 
	$message 
	--$boundary 
	Content-Type: $mimeType; name=$filename 
	Content-Disposition: attachment; filename=$filename 
	Content-Transfer-Encoding: base64 
	$content 
	--$boundary--"; 
	//发送邮件 
	mail( $to, $subject, $body, $header ); 
	 

永久链接:

转载随意!带上文章地址吧。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn