我正在发送电子邮件wp_mail()
功能,但它不工作。它正在返回false。此外,它在服务器日志中没有给出任何错误。
这是我的代码:
$mailResult = false;
$to = "[email protected]";
$subject = "HUDPowerBid Mailgun Test exec on ";
$message = "Testing Mailgun at: ";
$mailResult = wp_mail( $to, $subject, $message, $headers);
$myarr= array(\'error\' => true, \'mail\' => $mailResult);
I have also tried with the above code and below code also I have tried with these two codes at once but nothing is working
$to1 = \'[email protected]\';
$subject1 = \'Post Published by Author\';
$headers1 = \'From: admin <[email protected]>\' . "\\r\\n";
$message1 = \'your\';
$a=wp_mail($to1, $subject1, $message1, $headers1);
$my=array(\'checkstatus\'=>$a,\'second\'=>$mailResult);
echo json_encode($my);
SO网友:Andy Macaulay-Brook
虽然wp_mail
失败时返回false,它还包含一个操作挂钩,允许您访问错误信息。
如果phpmailer
发送失败,运行以下行:
/**
* Fires after a phpmailerException is caught.
*
* @since 4.4.0
*
* @param WP_Error $error A WP_Error object with the phpmailerException message, and an array
* containing the mail recipient, subject, message, headers, and attachments.
*/
do_action( \'wp_mail_failed\', new WP_Error( \'wp_mail_failed\', $e->getMessage(), $mail_error_data ) );
return false;
如果将函数附加到
wp_mail_failed
您可以查看
WP_Error
对象以获取有关您的问题的更多信息。