Find the answer to your Linux question:
Results 1 to 2 of 2
Hi all, I'm trying to embed a single image into my php mail function. Following the code part,when i receive the mail -image is shown as an attachment and not ...
  1. #1
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Question [SOLVED] Embed Images in php mail

    Hi all,
    I'm trying to embed a single image into my php mail function.
    Following the code part,when i receive the mail -image is shown as an attachment and not
    embedded into the mail.

    ===========
    //im using os commerce mailing functions,
    Code:
        $message = new email(array('X-Mailer: osCommerce Mailer'));
          $image = $message->get_file("/home/oss/galleria/shoppingcart/htmls/imgEng/Logo.jpg");
          $message->add_html_image($image, 'logo');
          $message->add_html($email_text, $text);
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Cool

    finally , I got it
    try this phpmailer instead of os commerce function
    Code:
    $mail = new PHPMailer();
    //$mail->IsSMTP(); // telling the class to use SMTP
    $mail->Host = "apprelay.trc.com"; // SMTP server
    $mail->From     = "lakshmipathi.g@gmail.com";
    $mail->FromName = "Mailer-Today";
    $mail->AddAddress("lakshmipathi.g@gmail.com"); 
    $mail->WordWrap = 50;                              // set word wrap
    $mail->AddEmbeddedImage("/home/oss/Logo.jpg", "my-attach", "Logo.jpg");
    $mail->Body = '<img alt="PHPMailer" src="cid:my-attach">  ';
    $mail->IsHTML(true);                               // send as HTML
    
    $mail->Subject  =  "image !!!!!!!!";
    $mail->AltBody  =  "This is the text-only body";
    
    if(!$mail->Send())
    {
       echo "Message was not sent <p>";
       echo "Mailer Error: " . $mail->ErrorInfo;
       exit;
    }
    
    echo "Message has been sent";
    Hope it helps somebody!!!!!!!!
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...