PHPMailer只是挂在发送电子邮件的地方

时间:2018-08-08 16:58:04

标签: php phpmailer

PHPMailer只是在发送电子邮件时挂起。我逐行注释了所有代码,一切正常,直到进入

if(!$ mail-> send())

这时页面进入旋转状态-没有错误消息或其他任何指示错误的信息。我想我有所有必需的$ mail->条目

所有文件都位于本地主目录中。

下面的完整代码

我一直试图让邮件代理运行2周-最初使用SMTP.js,但由于我们不知道的原因而停止工作。

任何帮助我们确定为什么PHPMailer会挂起的帮助

?php
namespace MyProject;    

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;

use PHPMailer\PHPMailer\Exception;

echo "uses done";


require 'vendor/autoload.php';

require_once 'PHPMailer.php';

require_once 'OAuth.php';

require_once 'Exception.php';

require_once 'SMTP.php';

require_once 'POP3.php';

echo "requires done";

$mail = new PHPMailer(true);

$mail->SMTPDebug = SMTP::DEBUG_SERVER;

$mail->SMTPDebug = 4; //Alternative to above constant

$mail->isSMTP();

$mail->Host = 'smtp.gmail.com';

$mail->SMTPAuth = true;

$mail->Port = 587;

$mail->SMTPDebug = true;

$mail->SMTPSecure = 'tls';

$mail->SMTPAuth = true;

$mail->Username = '****@gmail.com';

$mail->Password = '*****';

$mail->From = "****@****.org";

$mail->FromName = "RPI Registrations";

$mail->addAddress('*****n@**.com');

$mail->Subject = "RPI Examination Registration";

$mail->msgHTML('hello world');

$mail->addReplyTo("*****n@*****.org", "Reply");

echo "mail_composed";


//  $mail->addCC("cc@example.com");

//  $mail->addBCC("bcc@example.com");

$mail->isHTML(true);

// $mail->Body = "<i>Mail body in HTML</i>";

// $mail->AltBody = "This is the plain text version of the email content";

if(!$mail->send()) 
{
    echo "Mailer Error: " . $mail->ErrorInfo;
} 
else 
{
    echo "Message has been sent successfully";
}



?>  

1 个答案:

答案 0 :(得分:0)

另外,请分享您的错误日志。