如何加载PHPMailer或在哪里让PHPMailer在这个实例中使用 [英] How do you load PHPMailer into or where do you get PHPMailer to use in this instance
本文介绍了如何加载PHPMailer或在哪里让PHPMailer在这个实例中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在这个实例中加载PHPMailer或者让PHPMailer在哪里使用?
How do you load PHPMailer into or where do you get PHPMailer to use in this instance?
<?php
require_once('class.phpmailer.php');
//
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "ssl://smtp.gmail.com"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "gmail@gmail.com"; // GMAIL username
$mail->Password = "pass1"; // GMAIL password
$mail->From('gmail@gmail.com');
//$mail->AddReplyTo("gmail@gmail.com");
$mail->Subject = $subject;
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->Body=$body;
$mail->AddAddress($email);
//$mail->AddAttachment("images/phpmailer.gif"); // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
推荐答案
mail = new PHPMailer();
mail = new PHPMailer();
mail-> IsSMTP(); // 告诉班级使用SMTP
mail->IsSMTP(); // telling the class to use SMTP
mail-> ; Host = ssl://smtp.gmail.com; // SMTP服务器
mail->Host = "ssl://smtp.gmail.com"; // SMTP server
这篇关于如何加载PHPMailer或在哪里让PHPMailer在这个实例中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文