SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Phpmailer ...!!!!*#!! ...with embedded images and attachments

    hi, I have code below:
    It works fine untill I try to send email with embeddded image and attachment toghether...
    If I send email with one embedded image it works fine...
    If I send email with one attachment it works fine..
    but...
    If I send one embedded image plus one attachment Just the image arrives with mail..

    Too many forums tell to use phmmailer to get easy way BUT I spent 3 days trying to find solution for my problem and, probably, if I made my own php code now I was just working over on other things.

    Anyone can help me please?

    the code...


    <?php
    $messaggio = new PHPmailer();
    $messaggio->From='mail@mydomain.it';
    $messaggio->FromName ='Paolo Bartoli';

    $messaggio->AddReplyTo('mail@ mydomain.it');
    $messaggio->Subject=$subject;
    $messaggio->AddAddress($mail);
    $messaggio->ClearAttachments();
    $messaggio->CharSet = "UTF-8";

    if ($upl_img == 1) { $messaggio->AddEmbeddedImage($file, $file_name); }
    if ($upl_f == 1) { $messaggio->AddAttachment($attach); }
    $messaggio->IsHTML(true);
    $messaggio->Body = '<html><head><body><style>';
    $messaggio->Body .= '#body{background-color:#FFFFFF;color:#696969;font-size:12px;text-align:left;font:Arial,Helvetica,sans-serif}';
    $messaggio->Body .= 'b{color:#000000;font-weight:bold}';
    $messaggio->Body .= 'a{color:#CC0000;text-decoration:none;font-weight:bold}';
    $messaggio->Body .= 'h1{color:#000000;text-decoration:none;font-weight:bold;font-size:16px}';
    $messaggio->Body .= '</style>';
    if ($upl_img == 1) { $messaggio->Body .= "<img src='cid:".$file_name."' /><p />"; }
    $messaggio->Body .= $message;
    $messaggio->Body .= '<p /></body></html>';
    $messaggio->AltBody = $text_message;

    if(!$messaggio->Send()){ echo $messaggio->ErrorInfo; }
    $messaggio->ClearAddresses();
    unset($messaggio);

    $n++;
    $x++;
    if ($x == $hold)
    sleep(3);
    $x = 0;

    echo "<img src='../IMG/all/bar.png'>";
    ?>

  2. #2
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any?

    Quote Originally Posted by bartolix View Post
    hi, I Have Code Below:
    It Works Fine Untill I Try To Send Email With Embeddded Image And Attachment Toghether...
    If I Send Email With One Embedded Image It Works Fine...
    If I Send Email With One Attachment It Works Fine..
    But...
    If I Send One Embedded Image Plus One Attachment Just The Image Arrives With Mail..

    Too Many Forums Tell To Use Phmmailer To Get Easy Way But I Spent 3 Days Trying To Find Solution For My Problem And, Probably, If I Made My Own Php Code Now I Was Just Working Over On Other Things.

    Anyone Can Help Me Please?

    The Code...


    <?php
    $messaggio = New Phpmailer();
    $messaggio->from='mail@mydomain.it';
    $messaggio->fromname ='paolo Bartoli';

    $messaggio->addreplyto('mail@ Mydomain.it');
    $messaggio->subject=$subject;
    $messaggio->addaddress($mail);
    $messaggio->clearattachments();
    $messaggio->charset = "utf-8";

    If ($upl_img == 1) { $messaggio->addembeddedimage($file, $file_name); }
    If ($upl_f == 1) { $messaggio->addattachment($attach); }
    $messaggio->ishtml(true);
    $messaggio->body = '<html><head><body><style>';
    $messaggio->body .= '#body{background-color:#ffffff;color:#696969;font-size:12px;text-align:left;font:arial,helvetica,sans-serif}';
    $messaggio->body .= 'b{color:#000000;font-weight:bold}';
    $messaggio->body .= 'a{color:#cc0000;text-decoration:none;font-weight:bold}';
    $messaggio->body .= 'h1{color:#000000;text-decoration:none;font-weight:bold;font-size:16px}';
    $messaggio->body .= '</style>';
    If ($upl_img == 1) { $messaggio->body .= "<img Src='cid:".$file_name."' /><p />"; }
    $messaggio->body .= $message;
    $messaggio->body .= '<p /></body></html>';
    $messaggio->altbody = $text_message;

    If(!$messaggio->send()){ Echo $messaggio->errorinfo; }
    $messaggio->clearaddresses();
    Unset($messaggio);

    $n++;
    $x++;
    If ($x == $hold)
    Sleep(3);
    $x = 0;

    Echo "<img Src='../img/all/bar.png'>";
    ?>


Bookmarks

Posting Permissions

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