I'm trying to sending an image via email

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi gang:

I'm trying to send an image via email (hmm, must be an echo).

In any event, the following is my main-code (word, dude) and a part of the email I receive back. The image file IS there.

Any suggestions as to what I'm doing wrong?

Cheers,

tedd

-- the code --

$eol="\r\n";
$mime_boundary=md5(time());

$headers = "From: ".$myName."<".$from.">".$eol;
$headers .= "Reply-To: ".$myName."<".$from.">".$eol;
$headers .= "Return-Path: ".$myName."<".$from.">".$eol;
$headers .= "Message-ID: <".time()."-".$from.">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;

$handle=fopen($filename, 'rb');
$f_contents=fread($handle, filesize($filename));
$f_contents=chunk_split(base64_encode($f_contents));
fclose($handle);

$msg = "--".$mime_boundary.$eol;
$msg .= "Content-Type: image/jpeg; name=\"".$filename."\"".$eol;
$msg .= "Content-Transfer-Encoding: base64".$eol;
$msg .= "Content-Disposition: attachment; filename=\"".$filename."\"".$eol.$eol;
$msg .= $f_contents.$eol.$eol;

mail($to, $subject, $msg, $headers);

-- what I receive --

X-Mailer: PHP v5.1.6
MIME-Version: 1.0
Content-Type: multipart/related; boundary="d4a13b4aa61d40214e49820c8f2e2e2f"

--d4a13b4aa61d40214e49820c8f2e2e2f

Content-Type: image/jpeg; name="tempa.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="tempa.jpg"

/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAZAAA/+4AJkFkb2JlAGTAAAAAAQMA
-snip- more of the same


--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux