我正在尝试使用 Mailtrap 来测试从我的本地主机环境(在 Xampp、Mac OS 上运行的 Wordpress)发送的电子邮件。
我将mailtrap给我的代码实现到functions.php中:
function mailtrap($phpmailer) {
$phpmailer->isSMTP();
$phpmailer->Host = 'smtp.mailtrap.io';
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 2525;
$phpmailer->Username = '***-cd4b';
$phpmailer->Password = '***-239a';
}
add_action('phpmailer_init', 'mailtrap');
我制作了一个 php 文件,我尝试使用以下代码发送电子邮件:
$to = "benviat@gmail.com";
$subject = 'my subject';
$message = 'I would like to work with you';
$headers[] = 'From: Ben<bviatte@gmail.com>';
$sent_message = wp_mail( $to, $subject, $message, $headers);
var_dump($sent_message);
if ( $sent_message ) {
echo 'The test message was sent. Check your email inbox.';
} else {
echo 'The message was not sent';
}
但是,我得到的只是“未发送此消息”。
当我检查错误日志时,我得到的是:AH00169: 捕获 SIGTERM,正在关闭
以及一个:AH01906:localhost:443:0 服务器证书是CA证书
任何建议将不胜感激!