Skip to content

Instantly share code, notes, and snippets.

@tournasdim
Created June 25, 2013 07:33
Show Gist options
  • Save tournasdim/5856668 to your computer and use it in GitHub Desktop.
Save tournasdim/5856668 to your computer and use it in GitHub Desktop.
Sending mail with attachment using the PHPMailer Class
<?php
/*
First downlaod the library from Google
http://code.google.com/a/apache-extras.org/p/phpmailer/
*/
require_once 'class.phpmailer.php';
$mail = new PHPMailer();
// Add the necessary stuff
// HTML body
$body = " <div style=\"width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 14px;background-color:beige;padding: 15px;\">";
$body .= " <font size=\"4\">Hello Dimitrios </font> <p>";
$body .= "<i>Your</i> personal photograph to this message.<p>";
$body .= "Sincerely, <br>";
$body .= "phpmailer test message ";
$body .= "</div>" ;
// And the absolute required configurations for sending HTML with attachement
$mail->AddAddress("sendemailto@mail.zz", "My-webpage Website" );
$mail->Subject = "test for phpmailer-3";
$mail->MsgHTML($body);
$mail->AddAttachment("phpmailer.gif");
if(!$mail->Send()) {
echo "Error , couldn't send the message" ;
exit;
}
echo "Your message was sent successfully" ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment