Solved

PHP image in email

Posted on 2008-06-18
4
245 Views
Last Modified: 2012-05-05
Hi, can anyone tell me if there's a quick and simple way to add an image to my php mail script which displays the image on the email received?

Thanks!
0
Comment
Question by:zollgut
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Rurne
ID: 21816613
If it's an HTML email, then you can just link it in the HTML.  If not, then you will have to add it as an attachment.  Depending on your mail code, this can be easy, or it can mean having to base64_encode the image and hacking out your own multipart/mixed sections.

What's your current email code look like?
0
 

Author Comment

by:zollgut
ID: 21816946
Hi, Thanks for your help Rurne

Its using php, i've tried using a simple link but this obviously didnt work :D

A sample of the code used below:

$from3 = "email@domain.com";

$to3 = Trim(stripslashes($_POST['email']));

$subject3 = "Booking Confirmation";
 

$body3 = "";

$body3 = '<img src="http://www.domain.com/logo.jpg" />';

$body3 .= " ";

$body3 .= "\n";

$body3 .= "\n";

$body3 .= "Number of Delegates :";

$body3 .= " ";

$body3 .= $delegatenum;

$body3 .= "\n";

$body3 .= "\n";

$body3 .= "Your booking has been confirmed. Thank you.";

$body3 .= "\n";

$body3 .= "\n";
 
 

$success3 = mail($to3, $subject3, $body3, "From: <$from3>");

Open in new window

0
 

Author Comment

by:zollgut
ID: 21817712
Can anyone help with the code above? thanks
0
 
LVL 9

Accepted Solution

by:
Rurne earned 100 total points
ID: 21817810
What do you get when you send that email?  If it comes through as plain text, you may need to include the appropriate comment type in the mail headers:
$from3 = "email@domain.com";

$to3 = Trim(stripslashes($_POST['email']));

$subject3 = "Booking Confirmation";

 

$body3 = "";

$body3 = '<img src="http://www.domain.com/logo.jpg" />';

$body3 .= " ";

$body3 .= "\n";

$body3 .= "\n";

$body3 .= "Number of Delegates :";

$body3 .= " ";

$body3 .= $delegatenum;

$body3 .= "\n";

$body3 .= "\n";

$body3 .= "Your booking has been confirmed. Thank you.";

$body3 .= "\n";

$body3 .= "\n";

 

$headers3 = 'From: <'.$from3.'>'."\r\n";

$headers3 .= 'Content-Type: text/html; charset="iso-8859-1"';
 

$success3 = mail($to3, $subject3, $body3, $headers3);

Open in new window

0

Featured Post

Do email signature updates give you a headache?

Do you feel like you are constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Resolve DNS query failed errors for Exchange
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now