Solved

PHP image in email

Posted on 2008-06-18
4
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
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 email address policy 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…

636 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