Solved

PHP image in email

Posted on 2008-06-18
4
251 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Resolve DNS query failed errors for Exchange
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 video we show how to create a Distribution Group 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 Recipients >>…
In this video we show how to create a Shared Mailbox 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 Recipients >> Sha…

751 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