PHP - Image - Mail [SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

PHP - Image - Mail [SOLVED]

Post by tecktalkcm0391 »

Can you have PHP mail an image, and only an image? Would you just do the image code and then have the output in a variable, and then do something like

Code: Select all

mail(email@site.com, '', $imagefile);
?
Last edited by tecktalkcm0391 on Wed Jun 07, 2006 10:00 pm, edited 1 time in total.
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

yes you can. You have to attach the file. look here http://www.php.net/function.mail there are acouple of examples
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Re: PHP - Image - Mail

Post by tecktalkcm0391 »

So this should work?

Code: Select all

$header  = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail(email@site.com, '', $imagefile, $header);
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

prolly not, check the manual it has a few examples.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

So you want the image embedded inside your email instead of a soft link (via HTTP)?

You realize that this will quickly use up bandwidth right? Sending a 64KB image to 1000 people...requires alot of it...

Anyways, if I remember correctly...I believe phpMailer makes it quite easy to do this...perhaps it was just attachments...but in anycase...use that class as it will make your mailing life 10 times easier :)

Perhaps you could even look into d11's mailer class...it might do something like this...???

Cheers :)
Post Reply