Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP image in email

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Want to know how to use Exchange Server Eseutil command? Go through this article as it gives you the know-how.
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

704 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