Sending mails with attach? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Sending mails with attach?

ljubaljuba Posts: 106Member
Is here somebody who has some example for this?

PS: Is there any quota for size of attached files?

Thanks a lot



  • ljubaljuba Posts: 106Member

    $mail = new phpmailer();
    $mail->IsSMTP(); // send via SMTP
    $mail->Host = ";"; // SMTP servers
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->Username = "jswan"; // SMTP username
    $mail->Password = "secret"; // SMTP password
    $mail->From = "[email protected]";
    $mail->FromName = "Mailer";
    $mail->AddAddress("[email protected]","Josh Adams");
    $mail->AddAddress("[email protected]"); // optional name
    $mail->AddReplyTo("[email protected]","Information");
    $mail->WordWrap = 50; // set word wrap
    $mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
    $mail->AddAttachment("/tmp/image.jpg", "new.jpg");
    $mail->IsHTML(true); // send as HTML
    $mail->Subject = "Here is the subject";
    $mail->Body = "This is the HTML body";
    $mail->AltBody = "This is the text-only body";
    echo "Message was not sent

    echo "Mailer Error: " . $mail->ErrorInfo;
    echo "Message has been sent";
    Win :
    Unix :

Sign In or Register to comment.