PHP电子邮件功能不起作用未收到确认电子邮件

时间:2020-10-28 05:45:58

标签: php ajax

PHP邮件发送功能不起作用。用户提交产品计算表时,没有收到我添加到functions.php文件中的用户确认电子邮件。 试图解决这个难题很长一段时间,现在寻求您的帮助。 这是网站链接-

表格- 产品计算表

PHP

add_action("wp_ajax_sentemail", "so_wp_ajax_function");
add_action("wp_ajax_nopriv_sentemail", "so_wp_ajax_function");

function so_wp_ajax_function() {
    $params = array();
    parse_str($_POST['formData'], $params);

    $to = "info@nuhaus.ie";
    $subject = "PRODUCT CALCULATION";

    $message = '
Name: ' . $params['first_name'] . ' ' . $params['last_name'] . ' <br /> <br />
Email: ' . $params['email'] . ' <br /> <br />
Phone: ' . $params['phone'] . ' <br /> <br />
Message: ' . $params['message'] . ' <br /> <br />
SQM: ' . $params['sqm'] . ' <br /> <br />
Extras: ' . implode(', ', $params['extras']) . ' <br /> <br />
Total Amount: ' . $params['total_amount'] . ' <br /> <br />
';

    // Always set content-type when sending HTML email
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

    //$headers .= 'From: <email@outroom.ie>' . "\r\n";
$headers .= 'From: ' . $params['first_name'] . ' ' . $params['last_name'] . ' <' . $params['email'] . '>' . "\r\n";
    
    $retval = mail($to,$subject,$message,$headers);

    $to = $params['email'];
    $subject = "Thanks for contacting us";
    $message = '
Dear ' . $params['first_name'] . ' ' . $params['last_name'] . ',

Thank you for contacting outroom team.

We will be in contact with you to discuss your home improvement project. Outroom team includes architectural designers, engineers, estimators and builders, all with one goal in mind: to help your vision be realized.

We are here to design, construct, certify and take care of everything in-between, producing superbly professional and top-quality finished home building.

More information about the team and our completed projects you can find visiting our website www.outroom.ie.

<br />
<br />
<br />
Best regards,
<br />
<br />
<br />
<img src="https://www.outroom.ie/wp-content/uploads/2020/09/logo-dark.png" />
';

    // Always set content-type when sending HTML email
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

    // More headers
    $headers .= 'From: Outroom <email@outroom.ie>' . "\r\n";
    //$headers .= 'Cc: myboss@example.com' . "\r\n";

    $retval1 = mail($to,$subject,$message,$headers);

    if( $retval == true ) {
        echo json_encode(array('status' => 'success'));
    } else {
        echo json_encode(array('status' => 'error'));
    }
    wp_die(); // ajax call must die to avoid trailing 0 in your response
}
?>

0 个答案:

没有答案