请教高手mail函数发送图片附件的问题? 谁能告诉我用imap怎么收附件! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个好,http://www.wisdomsoft.net/article.php?sid=123 我的问题是怎样将服务器的图片正确读入变量以作为mail附件为送。现在不管用各种方法读取时,收到邮件后的附件都是0字节。程序:$filename = "http://localhost/logo.jpg";$fp = fopen($filename,"r");$attachment = fread($fp,filesize($filename)); $attachment = base64_encode($attachment); $attachment = chunk_split($attachment); 另一段代码:--------------------------------------------------------$attachment = readfile($filename);$attachment = base64_encode($attachment); $attachment = chunk_split($attachment); //图片可以在浏览器上正确显示echo $attachment;发送为附件是仍然是0字节 早年是解决了的,你上面提到的也很对的base64后,应该每76个字符分段的。建议你看看别的邮件系统的实际邮件的格式以及相应的附件相关的资料。 $filename = "logo.jpg";$fp = fopen($filename,"rb");$attachment = fread($fp,filesize($filename)); $attachment = chunk_split(base64_encode($attachment)); 你把全部代码贴出来 是这样吗?发送后仍然是0字节的图片附件。全部代码如下:$from_name = "from";$from_email = "[email protected]";$to_name = "to";$to_email = "[email protected]";$subject = "image test";$content="sample text here.";$filename = "http://localhost/test/logo.jpg";$fp = fopen($filename,"rb");$attachment = fread($fp,filesize($filename)); $attachment = chunk_split(base64_encode($attachment)); $attch_filename = "test.jpg";$to = "$to_name <$to_email>";$boundary = uniqid( "");$headers = "From: $from_name <$from_email>Content-type: multipart/mixed; boundary=\"$boundary\"";$content = "--$boundaryContent-type: text/plain; charset=iso-8859-1Content-transfer-encoding: 8bit$content--$boundaryContent-type: image/jpg; name=$attch_filenameContent-disposition: attachment; filename=$attch_filenameContent-transfer-encoding: base64$attachment--$boundary--";mail($to,$subject,$content,$headers); 对手知道form表单里的字段,在恶意提交信息,怎么办? php上传字段保存到mysql 关于分页及URL的请教 .htaccess里如匹配问号 PHP没有加载MYSQL,都该了,就不知道哪里错了,请帮下吧? PHP 时间函数问题 php网站上传到域名的遇到的问题 如何获取发帖数? 如何获取服务器的操作系统 今天决定考研了,散分,为我来年成功庆祝!!!!!!!!!!!!!!!!!!!!!!!!!!!! 一个搞不明白的问题 template使用的问题!
http://www.wisdomsoft.net/article.php?sid=123
现在不管用各种方法读取时,收到邮件后的附件都是0字节。
程序:$filename = "http://localhost/logo.jpg";$fp = fopen($filename,"r");$attachment = fread($fp,filesize($filename)); $attachment = base64_encode($attachment); $attachment = chunk_split($attachment);
--------------------------------------------------------$attachment = readfile($filename);$attachment = base64_encode($attachment); $attachment = chunk_split($attachment); //图片可以在浏览器上正确显示
echo $attachment;发送为附件是仍然是0字节
base64后,应该每76个字符分段的。建议你看看别的邮件系统的实际邮件的格式
以及相应的附件相关的资料。
$filename = "logo.jpg";
$fp = fopen($filename,"rb");
$attachment = fread($fp,filesize($filename));
$attachment = chunk_split(base64_encode($attachment));
你把全部代码贴出来
$from_name = "from";
$from_email = "[email protected]";$to_name = "to";
$to_email = "[email protected]";$subject = "image test";
$content="sample text here.";
$filename = "http://localhost/test/logo.jpg";
$fp = fopen($filename,"rb");
$attachment = fread($fp,filesize($filename));
$attachment = chunk_split(base64_encode($attachment)); $attch_filename = "test.jpg";
$to = "$to_name <$to_email>";$boundary = uniqid( "");$headers = "From: $from_name <$from_email>
Content-type: multipart/mixed; boundary=\"$boundary\"";$content = "--$boundary
Content-type: text/plain; charset=iso-8859-1
Content-transfer-encoding: 8bit$content--$boundary
Content-type: image/jpg; name=$attch_filename
Content-disposition: attachment; filename=$attch_filename
Content-transfer-encoding: base64$attachment--$boundary--";mail($to,$subject,$content,$headers);