【发布时间】:2021-07-11 11:14:41
【问题描述】:
我正在使用 SMTP 发送电子邮件。为此,我使用了 WP Mail SMTP 插件 (https://wordpress.org/plugins/wp-mail-smtp/) 我使用 WP Mail SMTP 插件测试了邮件并且它可以工作。现在我想用我在 WordPress 模板中创建的 SMTP 功能发送邮件
这是我的模板文件代码
<?PHP
/* Template Name: smt */
get_header();
require '/PHPMailer/class.PHPMailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "******";
$mail->Username = "******";
$mail->Password = "***********";
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->From = "no-reply@*****.com";
$mail->FromName = "zaata";
$mail->AddAddress('anaiycvktquiech@gmail.com');
$mail->IsHTML(true);
$mail->Subject = "zaata Varification code";
$mail->Body = "testmail";
$mail->IsHTML(true);
if(!$mail->Send())
{
echo 'false';
}
echo 'send';
}
?>
它在控制台中显示 itsugestion.com/:1 GET *******.com/dev/smt/ 500 (Internal Server Error)
请帮助我如何在 WordPress 模板中设置 SMTP 任何帮助表示赞赏。
【问题讨论】:
-
查看debug log 以获取有关 500 内部服务器错误的更多详细信息并报告您的发现。
-
安装 wp-mail-smtp 后,您可以使用插件描述中的
wp_mail功能WP Mail SMTP plugin easily resolves email delivery problems by improving and changing how your WordPress site sends email. We reconfigure the wp_mail() function to either use proper SMTP host credentials or leverage a built-in SMTP mail provider.
标签: php wordpress email smtp custom-wordpress-pages