PHP Mail无法正常工作

时间:2013-10-29 21:04:51

标签: php html email

我有一个很长的表格,表格的内容是通过邮件发送的(HTML电子邮件)。

我的PHP邮件功能非常适用于其他内容。但是,当我将以下内容添加到邮件正文时,邮件无法正常工作。

<h4><span style="text-decoration:underline">OCCUPATION:</span></h4>

<p>Please provide a specific and identifiable business activity and
your current position . Vague references such as"Businessman" or
"Manager" will not be accepted and will delay the incorporation
process. In the case of no employment please describe the normal
day to day activities such as "House Wife" In case of retirement
please provide details of previous occupation and your last
position.<br />
<textarea name="personal_information_occupation">

</textarea></p>
<hr />

我经历了每一行,但找不到这些特殊线路的错误。

我的PHP邮件发送HTML电子邮件。

<?php

if(mail($to, $subject, $message, $headers)){
            $mail_status_message = "<p class='success-msg'> Form Submitted Successfully. </p>";
        }else{
            $mail_status_message = "<p class='error-msg'> Something went wrong. Please try again later. </p>";
        }

?>

基本上,当我将上述代码添加到邮件正文时,我收到了Something went wrong. Please try again later

邮件标题

    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    // Additional headers
    $headers .= 'To: '.$to_name.'<'.$to_email.'>' . "\r\n";
    $headers .= 'From: Business Name <email@example.com>' . "\r\n";

1 个答案:

答案 0 :(得分:0)

如果您的mail()函数调用返回FALSE并且您没有收到PHP错误,则表明您的邮件服务器出现问题。邮件正在发送到邮件服务器,但由于某种原因未被接受。究竟是什么原因取决于PHP服务器和邮件服务器的配置,因此您必须检查邮件服务器的日志以找出发生的情况。见How can I get the error message for the mail() function?