【问题标题】:PHP Mail not working properlyPHP 邮件无法正常工作
【发布时间】:2013-11-09 05:59:57
【问题描述】:

我有一个很长的表格,表格的内容是通过邮件(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";

【问题讨论】:

  • 定义“不工作”。
  • 当我从$body = ' ';部分删除代码时正在发送邮件,当我再次添加它时,邮件没有发送。
  • 请发布您正在使用的代码以及正在生成的错误。
  • 邮件代码只有大约 800 行,我没有收到任何错误消息。
  • 那么您的mail 方法是什么样的?

标签: php html email


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-25
    • 2019-02-07
    • 2011-07-14
    • 1970-01-01
    • 1970-01-01
    • 2021-07-05
    相关资源
    最近更新 更多