据我所知,你没有得到其余的代码,所以我可以看到有什么问题,所以我会向你发布我使用 gmail 发送电子邮件的代码
代码 :
$sendmail = require_once('../lib/phpmailer/class.phpmailer.php');
include("../lib/phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = " Body Msg ";
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "smtp.gmail.com"; // sets the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "mail@gmail.com"; // SMTP account username
$mail->Password = "pass"; // SMTP account password
$mail->SetFrom('$qemail', 'first name');
$mail->Subject = "hi name";
$mail->MsgHTML($body);
$address = "mail@gmail.com";
$mail->AddAddress($address, "first name");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
如果您愿意尝试代码,请不要忘记在 include 函数和 require_once 中为类设置正确的位置