Email with attachment + php

Discussion in 'PHP' started by ksamir2004, May 12, 2008.

  1. #1
    Hi All,

    Can any one help me to send email with attachment in php.. please send the script.

    Thank
     
    ksamir2004, May 12, 2008 IP
  2. DeFacto

    DeFacto Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hope this is what you are looking for: http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php
     
    DeFacto, May 12, 2008 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
  4. gigamike

    gigamike Active Member

    Messages:
    165
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Mate,

    use this one

    http://phpmailer.codeworxtech.com/

    easy to use

    require("class.phpmailer.php");

    $mail = new PHPMailer();

    $mail->From = "list@mydomain.com";
    $mail->FromName = "List manager";
    $mail->Host = "smtp1.site.com;smtp2.site.com";
    $mail->Mailer = "smtp";

    @MYSQL_CONNECT("localhost","root","password");
    @mysql_select_db("my_company");
    $query = "SELECT full_name, email, photo FROM employee WHERE id=$id";
    $result = @MYSQL_QUERY($query);

    while ($row = mysql_fetch_array ($result))
    {
    // HTML body
    $body = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
    $body .= "<i>Your</i> personal photograph to this message.<p>";
    $body .= "Sincerely, <br>";
    $body .= "PHPMailer List manager";

    // Plain text body (for mail clients that cannot read HTML)
    $text_body = "Hello " . $row["full_name"] . ", \n\n";
    $text_body .= "Your personal photograph to this message.\n\n";
    $text_body .= "Sincerely, \n";
    $text_body .= "PHPMailer List manager";

    $mail->Body = $body;
    $mail->AltBody = $text_body;
    $mail->AddAddress($row["email"], $row["full_name"]);
    $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");

    if(!$mail->Send())
    echo "There has been a mail error sending to " . $row["email"] . "<br>";

    // Clear all addresses and attachments for next loop
    $mail->ClearAddresses();
    $mail->ClearAttachments();
    }


     
    gigamike, May 12, 2008 IP
  5. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #5
    whoa gigamike of phpug...

    tnx for posting this one.. i need it too.. ^^,
     
    bartolay13, May 12, 2008 IP