tournasdim
6/25/2013 - 7:33 AM

Sending mail with attachment using the PHPMailer Class

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" ;