$content = chunk_split(base64_encode(file_get_contents('test.dpa')));
$uid = md5(uniqid(time()));
$header = "From: mail@mail.com\r\nReply-To: mail@mail.com\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= $msg."\r\n\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-Type: application/octet-stream; name=\"test.dpa\"\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"test.dpa\"\r\n\r\n";
$header .= $content."\r\n\r\n";
if( mail($_POST['email'], 'TESTING MAIL', "", $header ) )
echo "SUCCESS !";
else
echo "NOPE !";
I want to send a mail with attachment. I'm formatting the $msg
from a completed form. - test.dpa - is a file.
My problem is with the statement. Why the statement is FALSE ? I'm getting the "NOPE" result if I want to send the mail. But why? Where is the problem? I don't get it.