2 回答
TA贡献1827条经验 获得超4个赞
这听起来像是网络/系统管理员问题,而不是 PHPMailer 问题。试试
telnet smtp.gmail.com 587 // host and port
在您的控制台中,用于检查连通性。如果一切正常,它应该写一条消息,如“ESMTP MAIL 服务就绪”。否则,该服务器会阻止您的服务器。
TA贡献1785条经验 获得超8个赞
请在您的文件中添加类 smtp 或使用此代码并相应地更改凭据它将起作用。
include_once('class.phpmailer.php');
require_once('class.smtp.php');
$name = strip_tags($_POST['full_name']);
$email = strip_tags ($_POST['email']);
$msg = strip_tags ($_POST['description']);
$subject = "Contact Form from DigitDevs Website";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "mail.example.com"; // SMTP server example
//$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "info@example.com"; // SMTP account username example
$mail->Password = "password"; // SMTP account password example
$mail->From = $email;
$mail->FromName = $name;
$mail->AddAddress('info@example.com', 'Information');
$mail->AddReplyTo($email, 'Wale');
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $msg;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
- 2 回答
- 0 关注
- 115 浏览
添加回答
举报