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

Embed company logo in an html email

P: 107
I am trying to embed company logo (image) in an html email which i am sending using PHP mail function. I tried the following way but didnt work. So, I am not sure how to go about. Please see my code below and advice me.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $to       = "";
  3. $subject  = "Test Mail";
  4. $body     = "<html><br>";
  5. $body    .= "<head><title>Test Mail</title></head>";
  6. $body    .= "<body>";
  7. $body    .= "<img src=\"\" width=\"100%\">"; 
  8. $body    .= "</body>";
  9. $body    .= "</html>";
  11. $headers .= "From: Me<\r\n"; 
  12. $headers .= "Reply-To: Me<\r\n"; 
  13. $headers .= "Return-Path: Me<\r\n"; 
  14. $headers .= "MIME-Version: 1.0\r\n"; 
  15. $headers .= "Content-Type: multipart/alternative; charset=ISO-8859-1\r\n"; 
  17. $sent = @mail($to, $subject, $body, $headers,"-f");
  19. if($sent){
  20.            echo "Successful!"
  21.  }   
  22. else{
  23.            echo "Un-successful!"
  24. }     
  25. ?>
Apr 10 '09 #1
Share this Question
Share on Google+
3 Replies

Expert 5K+
P: 6,050
What do you mean 'it did not work'.

I don't see any obvious error, but mail() isn't a strong point of mine.

Many mail clients will not allow pictures to be sent via email; most require you enable them somehow.
Apr 10 '09 #2

P: 107
Sorry for not being clear in my earlier post. As you say there is no problem in the code but when i send mail, it doesnt get delivered.The mail() function returns me negative (false) output. I am using ArgoSoft for windows as the Mail Server. If i use the same code without the picture and content-type changed to html/text, the mail gets delivered.
Apr 11 '09 #3

Expert Mod 5K+
P: 8,639
if you have a SMTP server you might look into Swiftmailer, this makes sending even complex emails a piece of cake.
Apr 11 '09 #4

Post your reply

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