Jump to content


Photo

how to send images and html with the mail function


  • Please log in to reply
13 replies to this topic

#1 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 17 October 2006 - 11:35 PM

any body know how to send images and html with the mail function

thanks

#2 rab

rab
  • Members
  • PipPipPip
  • Advanced Member
  • 155 posts

Posted 17 October 2006 - 11:39 PM

mail()

Just have the message contain <img src="your img url" />

#3 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 18 October 2006 - 12:02 AM

can I design an html page and send it as it is ?

thanks

#4 rab

rab
  • Members
  • PipPipPip
  • Advanced Member
  • 155 posts

Posted 18 October 2006 - 12:25 AM

if they have html enabled in their email client then yes, they can view the site you designed

#5 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 18 October 2006 - 11:52 PM

so how to import the html file I designed

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 18 October 2006 - 11:56 PM

mail code to use html format .

add a image as advised above you also need to add the full url to the image from the image src.

example
echo"<img scr='http://www.what_ever.com/folder/image.jpg'></img>";

This code was provided from php.net there are meny example on there please take a look good luck
<?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);
?> 

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 19 October 2006 - 01:13 AM

many thanks , that what I want

#8 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 26 October 2006 - 02:51 PM

after alot of test some times the script work and some other times nothing happened, any help

do I have to use smtp to be sure of sending the emails

thanks

#9 php_joe

php_joe
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 26 October 2006 - 03:10 PM

You probably have to set your headers to HTML, like this:

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Your Name <your_address@example.com>' . "\r\n";

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

[url=http://darkswordsguide.com][/url]

#10 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 26 October 2006 - 03:38 PM

I did exactly like redarrow said

#11 php_joe

php_joe
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 26 October 2006 - 03:42 PM

I did exactly like redarrow said


But you said it didn't work, right?

Try adding the 'Content-type: text/html; charset=iso-8859-1' to your header. The code that I gave you works fine for me.

Joe
[url=http://darkswordsguide.com][/url]

#12 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 26 October 2006 - 05:39 PM

YES, he also told me that , recheck redarrow post and scroll down !!! you will see he also give me that line
'Content-type: text/html; charset=iso-8859-1' . "\r\n";

#13 php_joe

php_joe
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 26 October 2006 - 05:41 PM

yep, you're right.

nevermind :)
[url=http://darkswordsguide.com][/url]

#14 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 29 October 2006 - 12:10 AM

I found a good example and it work,
now I need to know where I should store the images I include in the page that will be sent by mail

thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users