require 'php-mailer/class.phpmailer.php';
require 'php-mailer/class.smtp.php';
require 'php-mailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 0;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'name@gmail.com';
$mail->Password = '********';
$mail->SMTPSecure = 'tsl';
$mail->Port = 587;
$mail->From = 'example@gmail.com';
$mail->FromName = 'example';
$mail->isHTML(true);
$mail->SetFrom('example@gmail.com', 'example');
$mail->AddReplyTo('example@gmail.com','example');
$mail->Subject = 'My Subject';
$mail->Body = 'Content Mail';
$mail->AltBody = '';
$mail->AddAddress('me@gmail.com', 'My Name');
//$mail->AddAttachment('images/phpmailer.gif');
//$mail->AddAttachment('images/phpmailer_mini.gif');
if(!$mail->send()){
echo "<h2 style='color:#df0000'>Email not sent!.</h2>";
echo $mail->ErrorInfo;
}
else{
echo "<h1>Success !!!</h1>";
}
提前谢谢