Hi Mac
How are you? Longest time.
Please im having problem with the script below:-
it sends email with the attachment, but the attachment does not display (a JPG file).
<html>
<head><title>Send email with attachment</title></head>
<body>
<h1>Send email with attachment</h1>
<?php
$to = "myemail@gmail.com";
$subject = "Web Mail";
$message = "This email has attachment";
$attachment = "Notification.JPG";
$attachment_MIME_type = "image/jpeg";
$handle = fopen($attachment, "rb"
;
$data = fread($handle, filesize($attachment));
fclose($handle);
$boundary = "---Multipart_Boundary---";
$headers = "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"" . $boundary . "\"";
$data = chunk_split(base64_encode($data));
$text = "--" . $boundary . "\n" .
"Content-Type:text/plain\nContent-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n--" . $boundary . "\n" .
"Content-Type: " . $attachment_MIME_type . ";\n name =\"" .
$attachment . "\"\nContent-Transfer-Encode: base64\n\n" .
$data . "\n\n--" . $boundary . "--\n";
$result = @mail($to, $subject, $text, $headers);
if($result)
{
echo "the email was sent.";
}
else
{
echo "The email was not sent.";
}
?>
</body>
</html>