在本地主机上运行PHPMailer时,将发送邮件,但是承载PHPMailer时会显示错误,因为SMTP连接()失败。https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting。请帮帮我。
这是我的密码
<?php
//include PHPMailerAutoload.php
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = 'mail@gmail.com';
$mail->Password = 'password';
$mail->setFrom('mail@gmail.com', 'mail');
$mail->addAddress('mail@gmail.com');
$mail->Subject = 'SMTP email test';
$mail->Body = 'Thanks for commenting';
if ($mail->send())
echo "mail is sent";
else
echo $mail->ErrorInfo;
?>发布于 2018-11-01 10:25:43
好吧,让我们把它说清楚:
vardump or something else“我的守则”样本:
require(https://example.com/PHPMailerAutoload.php');
require(https://example.com/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'mail.example.com';
$mail->SMTPAuth = TRUE;
$mail->Username = 'customer_service@example.com';
$mail->Password = 'blablabla';
$mail->From = 'customer_service@example.com';
$mail->setFrom('customer_service@example.com', 'My Cool Website');
$mail->AddAddress('recipient@destination.com', 'Recipient Full Name');
$mail->WordWrap = 70;
$mail->Subject = 'PHP Mailer';
$mail->Body = 'Awesome';
$mail->IsHTML(TRUE);https://stackoverflow.com/questions/53096573
复制相似问题