Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP image in email

Posted on 2008-06-18
4
Medium Priority
?
263 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 300 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One-stop solution for Exchange Administrators to address all MS Exchange Server issues, which is known by the name of Stellar Exchange Toolkit.
Want to know how to use Exchange Server Eseutil command? Go through this article as it gives you the know-how.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

885 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