send email like a webpage should have Image at the top

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
shafiq2626
Forum Commoner
Posts: 88
Joined: Wed Mar 04, 2009 1:54 am
Location: Lahore
Contact:

send email like a webpage should have Image at the top

Post by shafiq2626 »

Hi!
i want to send email like a webpage should have Image at the top of the body please help me that how this will be possible.
thanking you
lshaw
Forum Commoner
Posts: 69
Joined: Mon Apr 20, 2009 3:40 pm
Location: United Kingdom

Re: send email like a webpage should have Image at the top

Post by lshaw »

Are you saying you want to send an HTML email? if so, you can set the content-type to text/html

Code: Select all

 
$to="person@mail.com";
$subject="Hello";
$body="<img src='http://you.com/image.jpg' />Hi"; //the image is in here (from a remote site)
$headers   ="From:you@yourmail.com\r\n";
$headers . ="Content-type:text/html"; //render HTML tags
mail($to,$subject,$body,$headers);
 
dejvos
Forum Contributor
Posts: 122
Joined: Tue Mar 10, 2009 8:40 am

Re: send email like a webpage should have Image at the top

Post by dejvos »

Hi,
it's depends on where do you want to have image stored. You can put it on server ... So you can use classical html <img /> element or you can have these in the attachement ... example is here.

Hint: I have a bad experience with a putting images into an attachement. The problem is in mail clients which are not able to display images properly. If you place images on some server it will work every time but the annoying message about external images is displayed before the downloading.

For sending emails use PHPMailer package:
http://www.askapache.com/php/phpfreaks- ... orial.html
Post Reply