我花了一个小时试图弄清楚为什么wp\\u mail函数返回一个假布尔值。
这是我的密码。我通常可以让它工作,但现在似乎无法解决。我想这与我的服务器设置有关。
谢谢你的帮助。
<?php
$mail =\'\';
$errors = \'\';
if(isset($_REQUEST[\'contact_submit\'])) {
$contact_name = $_REQUEST[\'contact_name\'];
$contact_email = $_REQUEST[\'contact_email\'];
$contact_subject = $_REQUEST[\'contact_subject\'];
$contact_message = $_REQUEST[\'contact_message\'];
$errors = \'\';
// Checking if vars are all filled
if ( $contact_name != \'\' && $contact_email != \'\' && $contact_subject != \'\' && $contact_message != \'\' ) {
$to = \'[email protected]\';
$subject = \'Contact Form Submission\';
$body = \'<html><body><table>\';
if($contact_name) $body .= \'<tr><td><strong>Name: </strong></td><td>\'.$contact_name.\'</td></tr>\';
if($contact_email) $body .= \'<tr><td><strong>Email: </strong></td><td>\'.$contact_email.\'</td></tr>\';
if($contact_subject) $body .= \'<tr><td><strong>Phone Number: </strong></td><td>\'.$contact_subject.\'</td></tr>\';
if($contact_message) $body .= \'<tr><td><strong>Message: </strong></td><td>\'.$contact_message.\'</td></tr>\';
$body .= \'</table></body></html>\';
$headers = \'From: \' . $contact_name . \' <\' . $contact_email . \'>\' . "\\r\\n";
$headers .= \'Content-type: text/html\' . "\\r\\n";
$mail = wp_mail( $to, $subject, $body, $headers );
} else {
$errors = \'Please fill out all fields\';
}
}
?>