Jump to content


Photo

Graphics in php Email


  • Please log in to reply
3 replies to this topic

#1 blackerutuf

blackerutuf
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 05 July 2006 - 08:07 PM

Can anyone help me to include graphics in my php emails, currently I can only submit text, I would also like to be able to choose a text rather than just Time New Roman.
The current script is:

$headers = "MIME-Version: 1.0\n";
                                $headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: $from\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "X-Mailer: PHP/" . phpversion()."\n";
mail($to, $subject, $message, $headers);

Thanks in advance to anyone who can help

#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 05 July 2006 - 08:54 PM

This would be just normal HTML tags in your message
image example
<img src="http://www.domain.com/images/image.gif" border="0" alt="" />
Make sure you use a full path (http://....)

for different font, just change the style
<div style="font-family:arial; font-size:9pt;">
text
</div>

NoGray.com


#3 gausie

gausie
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts
  • LocationA Syntax Error

Posted 05 July 2006 - 08:55 PM

Hi blackerutuf

You have to send the email as HTML, and then specify images etc. within the HTML.

www.php.net says...

<?php
// multiple recipients
$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
  <title>Birthday Reminders for August</title>
</head>
<body>
  <p>Here are the birthdays upcoming in August!</p>
  <table>
   <tr>
     <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
   </tr>
   <tr>
     <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
   </tr>
   <tr>
     <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
   </tr>
  </table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>

The important bits there are that you should include

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";


within your headers and also lay out the email as a html page

Hope that helps

Sam
Inner Dreams My pen is there always - as inner dreams

Just remember: united, we are an idiot

#4 blackerutuf

blackerutuf
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 07 July 2006 - 08:00 PM

Thanks everyone Iwill give it a go




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users