Welcome! Log In Create A New Profile

Advanced

Back again

Posted by happy4u 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Back again
October 13, 2009 11:04AM
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"winking smiley;
$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>
avatar
Mac
Re: Back again
October 15, 2009 09:56AM
Eish - it would be daring of me to start giving support outside the course!
Sorry, only registered users may post in this forum.

Click here to login