note 43892 rejected from ref.mail by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 07 Jul 2004 13:51:16 +0000 |
| Subject: | note 43892 rejected from ref.mail by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72830@lists.php.net to get a copy of this message | ||
Note Submitter: crepin.antoine@netcourrier.com
----
Could anyone tells me why my script doesn't work??
I receive the email but the attachment is not readable, why??
Please help me !!!!
here is my code :
<?php
function xmail($email_address,$email_from,$subject,$msg,$attach_filepath) {
$b = 0;
$mail_attached = "";
$boundary = md5(uniqid(time(),1))."_xmail";
if (count($attach_filepath)>0) {
for ($a=0;$a<count($attach_filepath);$a++) {
if ($fp = fopen($attach_filepath[$a],"rb")) {
$file_name = basename($attach_filepath[$a]);
$content[$b] = fread($fp,filesize($attach_filepath[$a]));
$mail_attached .= "--".$boundary."\r\n"
."Content-Type: image/gif; name=\"$file_name\"\r\n"
. "Content-Transfer-Encoding: base64\r\n"
. "Content-Disposition: inline;
filename=\"$file_name\"\r\n\r\n"
.chunk_split(base64_encode($content[$b]))."\r\n";
$b++;
fclose($fp);
//test if i can show the attachment
echo "file opened!<br><html><body><img
src=".$file_name."></body></htm>";
} else {
echo "NEIN";
}
}
$mail_attached .= "--".$boundary." \r\n";
$add_header ="MIME-Version: 1.0\r\nContent-Type: multipart/mixed;
boundary=\"$boundary\"";
$mail_content = "--".$boundary."\r\n"
. "Content-Type: text/plain; charset=iso-8859-1; format=flowed\r\n"
. "Content-Transfer-Encoding: 8bit\r\n\r\n"
. $msg."\r\n\r\n".$mail_attached;
return mail($email_address,$subject,$mail_content,"From:
".$email_from."\r\n".$add_header);
} else {
return mail($email_address,$subject,$msg,"From: ".$email_from);
}
}
//------------------------------------
$email_address = "crepin.antoine@netcourrier.com";
//$email_cc = "";
//$email_bcc = ""; //there goes a copy to, too, but you can not see this emailaddress.
$email_from = 'me@there.net';
$subject = "c test";
$msg = '<html><body><center><font size=8>Le fichier est attaché
ci-dessus</font><br></body></html>';
$attach_filepath = array("picture.gif");
//$want_attach = true;
//------------------------------------
xmail($email_address,$email_from,$subject,$msg,$attach_filepath)
?>