Embed company logo in an html email

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raamay
    New Member
    • Feb 2007
    • 107

    Embed company logo in an html email

    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.
    Code:
    <?php
    $to       = "someone@somedomain.com";
    $subject  = "Test Mail";
    $body     = "<html><br>";
    $body    .= "<head><title>Test Mail</title></head>";
    $body    .= "<body>";
    $body    .= "<img src=\"http://www.mydomain.com/images/logo.jpg\" width=\"100%\">"; 
    $body    .= "</body>";
    $body    .= "</html>";
    		 
    $headers .= "From: Me<myself@mydomain.com\r\n"; 
    $headers .= "Reply-To: Me<myself@mydomain.com\r\n"; 
    $headers .= "Return-Path: Me<myself@mydomain.com\r\n"; 
    $headers .= "MIME-Version: 1.0\r\n"; 
    $headers .= "Content-Type: multipart/alternative; charset=ISO-8859-1\r\n"; 
    
    $sent = @mail($to, $subject, $body, $headers,"-f [email]myself@mydomain.com[/email]");
    		 
    if($sent){
               echo "Successful!"
     }   
    else{
               echo "Un-successful!"
    }     
    ?>
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    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.

    Comment

    • raamay
      New Member
      • Feb 2007
      • 107

      #3
      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.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        if you have a SMTP server you might look into Swiftmailer, this makes sending even complex emails a piece of cake.

        Comment

        Working...