【www.gdgbn.com--WebService】

 代码如下

//定义边界线
$boundary = uniqid( "" );
//生成邮件
$header = "From: $from Content-type: multipart/mixed;
boundary="$boundary" X-Mailer:PHP X-Priority:3";
//获取附件文件的MIME类型
$mimetype = mime_content_type("test.zip")
//获取附件文件的名字
$attach = "test.zip"
//对附件文件进行编码和切分
$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 );
?>

本文来源:http://www.gdgbn.com/asp/18263/