By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,903 Members | 1,593 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,903 IT Pros & Developers. It's quick & easy.

how can i include image with message send to mail

100+
P: 123
i have a website let assume it is www.mydomain.com i create an email in my control panel service@mydomain.com,am i to put the stmp configuration in my code below if so, why and where will i include it secondly in the message it want to include an image with the message so the receiver will so the message and the image(company logo) how can i do that.

Expand|Select|Wrap|Line Numbers
  1. $to = "Joe Doe <joe.doe@domain.com>";
  2. $from = "Paul Fred <service@mydomain.com>";
  3. $subject = "Happy Birthday!";
  4. $body =<<< END
  5. Hey Joe,
  6. Just wanted to wish you a happy 30th! Have a good one!
  7. Paul
  8. END;
  9. // send mail
  10. if (mail($to, $subject, $body, "From: $from")) {
  11. echo "Message successfully delivered to mail agent";
  12. } else {
  13. echo "Message could not be delivered to mail agent";
  14. }
  15.  
  16.  
Aug 20 '09 #1
Share this Question
Share on Google+
5 Replies


Dormilich
Expert Mod 5K+
P: 8,639
2 options (maybe more ;))

make a html email including the image

make a multipart message, depending on the email User Agent the picture may be shown along with the text.
Aug 20 '09 #2

100+
P: 123
Sorry the options you gave to me i do not no how to do any that is why i ask the question.
Aug 21 '09 #3

Markus
Expert 5K+
P: 6,050
Use the elegant SwiftMailer to send an HTML email.
Aug 21 '09 #4

100+
P: 123
the code below is for mail an i send an html email it work but the image i include did not display how can i make the image display

Expand|Select|Wrap|Line Numbers
  1.  <?php
  2.         if (isset($_POST['submit'])){
  3.             if(empty($_POST['name']) OR empty($_POST['email'])){
  4.             echo '<font color="#FF0000" size="2">You haven\'t filled in all the fields.</font>';
  5.             }else{
  6.         $name = ($_POST['name']);
  7.         $mail = ($_POST['email']);
  8.  
  9. // multiple recipients
  10. $to  = $mail;
  11. // subject
  12. $subject = 'You have just register with alinke';
  13.  
  14.                 // message
  15.                 $message = '<html>
  16.                 <head>
  17.                   <title>Alinke</title>
  18.                 </head>
  19.                 <body>
  20.                   <table>
  21.                     <tr>
  22.                 <th colspan="4"><img src="Alinke_files/logo.jpg" align="left"/></th>
  23.                 </tr>
  24.                 <tr>
  25.                   <th colspan="4" align="left">
  26.                    Dear $name<br>
  27.                       this is to remeder you that you have just register<br>
  28.                       with alinke you can now post your company information<br>
  29.                       logo and url.<br>
  30.                       to change your password click link below<br>
  31.                       http://www.alinke.com/test.php
  32.                  </th>
  33.                 </tr>
  34.               </table>
  35.                 </body>
  36.                 </html>';
  37.  
  38.             // To send HTML mail, the Content-type header must be set
  39.             $headers  = 'MIME-Version: 1.0' . "\r\n";
  40.             $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  41.  
  42.             // Additional headers
  43.             $headers .= 'From: Alinke <service@alinke.com>' . "\r\n";
  44.             // Mail it
  45.             mail($to, $subject, $message, $headers);
  46.             echo "Your Password Has Been Sent To Your Email Address.";
  47.         }
  48. }
  49.  
  50.  
  51. ?>
  52.  
Aug 27 '09 #5

hsriat
Expert 100+
P: 1,654
Hi simon2x1, you might have to provide the absolute address of the image.
<img src="http://www.yoursite.com/yourimage.png" alt="" />

And I still recommend you use SwiftMail or PHPMailer which are better than the mail() function of PHP.
Aug 31 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.