日期:2014-05-17 浏览次数:20456 次
function sendmail($setEmail, $setName, $body, $subject) {
require_once("PHPMail/phpmailer.php");
$mail = new PHPMailer ( true ); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP (); // telling the class to use SMTP
try {
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = SBT_SSL; // sets the prefix to the servier
$mail->Host = SBT_SMTP_HOST; // sets GMAIL as the SMTP server
$mail->Port = SBT_SMTP_PORT; // set the SMTP port for the GMAIL server
$mail->Username = SBT_SMTP_USER; // GMAIL username
$mail->Password = SBT_SMTP_PASS; // GMAIL password
$mail->AddReplyTo ( SBT_MAIL_FROM, SBT_MAIL_FROM_NAME );
$mail->AddAddress ( $setEmail, $setName );
$mail->SetFrom (SBT_SMTP_USER,SBT_SMTP_USER); //sender name
$mail->Subject = $subject;
$mail->MsgHTML ( $body );
if (! $mail->Send ()) {//(这边没报错)
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit ();
}
} catch ( phpmailerException $e ) {
echo $e->errorMessage (); //Pretty error messages from PHPMailer(就是这边输出错误的)
} catch ( Exception $e ) {
echo $e->getMessage (); //Boring error messages from anything else!
}
}