[PHP] I'm trying to sending an image via email

2007-12-30 Thread tedd

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/7AARRHVja3kAAQAEZAAA/+4AJkFkb2JlAGTAAQMA
-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



[PHP] Re: [BULK] [PHP] I'm trying to sending an image via email

2007-12-30 Thread Eddie Dunckley
On Sun 30 Dec 07, tedd wrote:
 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?

 -- the code --
 $msg .= Content-Disposition: attachment;
 filename=\.$filename.\.$eol.$eol;
 $msg .= $f_contents.$eol.$eol;

guess/think that should read:
$msg .= $f_contents.$eol. $boundary . --- . $eol;
i.e. message needs a closing boundary terminated with either 2 or 3 
dashes (cant remember off-hand).

-- 
Eddie
Most burning issues generate far more heat than light.

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



[PHP] Re: [BULK] [PHP] I'm trying to sending an image via email

2007-12-30 Thread Eddie Dunckley
 On Sun 30 Dec 07, tedd wrote:
  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?
 
  -- the code --
  $msg .= Content-Disposition: attachment;
  filename=\.$filename.\.$eol.$eol;
  $msg .= $f_contents.$eol.$eol;

On Mon 31 Dec 07, Eddie Dunckley wrote:
 guess/think that should read:
 $msg .= $f_contents.$eol. $boundary . --- . $eol;
 i.e. message needs a closing boundary terminated with either 2 or 3
 dashes (cant remember off-hand).

oops .. didnt read properly.
$msg .= $f_contents . $eol . '--' . $mime_boundary . --- . $eol.$eol;

send yourself an email with an attachment and view the email source and 
compare with your program output.

or you could just google for MIME.class site:*.phpbuilder.net and
download and use it like


require_once(MIME.class);

// check if parm bcc is in lib, think its not.
$msg = new MIME_mail($from, $to,$cc,$bcc, $subject); 

$msg-fattach($filename); 
// parms = $path, $description, $contenttype=OCTET, $encoding=BASE64,
//$disp='inline' etc, view the mime class to see options

$msg-send_mail();


-- 
Eddie
Dreams are free, but you get soaked on the connect time.

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



[PHP] Re: [BULK] [PHP] I'm trying to sending an image via email

2007-12-30 Thread tedd

oops .. didnt read properly.
$msg .= $f_contents . $eol . '--' . $mime_boundary . --- . $eol.$eol;

send yourself an email with an attachment and view the email source and
compare with your program output.




Yep, it's -- two hyphens.

Thanks,

tedd


--
---
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