PHP邮件功能在我的服务器上不起作用?

普里亚·in那

我的邮件功能在在线服务器上。运行正常。但是不是现在。我很困惑为什么它停止发送邮件了。它显示电子邮件已发送的消息,但收件箱中没有收到电子邮件。

这是我的PHP代码:

<?php
if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $message = $_POST['message'];

    $headers = "From: " . $email . "\n"; //from address
    $to = ""; //my mail id
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1 \n";
    $subject = "Test mail";

    $body = '<html>
        <head>
            <meta http-equiv="content-type" content="text/html; charset=utf-8" />
            <title>"."<h3>"."Hello Test,."</h3>".
    </title>
        </head>
        <body><p></p>
            <p style="color: #00CC66; font-weight:600; font-style:italic; font-size:14px; float:left; margin-left:7px;">You have received an inquiry from your website.  Please review the contact information below.

    :</p>';
    if (mail($to, $subject, $body, $headers)) {
        ?>
        <h3 style="color:#d96922; font-weight:bold; height:0px; margin-top:1px;">Thank You For Contacting us!!</h3>

        <?php
    } else {

        print_r(error_get_last());
    }
}

它出什么问题了?请帮助我找出解决方案。还可以帮助我回显错误吗?

刻板

我会尝试一下,在每行结尾\r\n并添加一个To头(可能看起来是多余的)。另外,charset=utf-8在标头中声明就足够了。如果不是,请确保它匹配(现在不匹配)。

<?php
  $subject = "Test mail";
  $to_email = "[email protected]";
  $to_fullname = "John Doe";
  $from_email = "[email protected]";
  $from_fullname = "Jane Doe";
  $headers  = "MIME-Version: 1.0\r\n";
  $headers .= "Content-type: text/html; charset=utf-8\r\n";
  // Additional headers
  // This might look redundant but some services REALLY favor it being there.
  $headers .= "To: $to_fullname <$to_email>\r\n";
  $headers .= "From: $from_fullname <$from_email>\r\n";
  $message = "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\r\n
  <head>\r\n
    <title>Hello Test</title>\r\n
  </head>\r\n
  <body>\r\n
    <p></p>\r\n
    <p style=\"color: #00CC66; font-weight:600; font-style: italic; font-size:14px; float:left; margin-left:7px;\">You have received an inquiry from your website.  Please review the contact information below.</p>\r\n
  </body>\r\n
  </html>";
  if (!mail($to_email, $subject, $message, $headers)) { 
    print_r(error_get_last());
  }
  else { ?>
    <h3 style="color:#d96922; font-weight:bold; height:0px; margin-top:1px;">Thank You For Contacting us!!</h3>
  <?php
  }
  ?>

为了避免出现通知/错误,我还将用以下内容替换第一行:

if ($_POST && isset($_POST['submit']) && isset($_POST['name']) && isset($_POST['email']) && !empty($_POST['name']) && !empty($_POST['email'])) {

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

PHP邮件功能在服务器上不起作用

来自分类Dev

php邮件功能在新服务器中不起作用

来自分类Dev

PHP邮件功能在Hostgator上不起作用

来自分类Dev

CakePHP邮件在服务器上不起作用

来自分类Dev

nodemailer的邮件在azure服务器上不起作用

来自分类Dev

selectizeInput在我的闪亮服务器上不起作用

来自分类Dev

会话在我的Web服务器上不起作用

来自分类Dev

PHP chmod()在服务器上不起作用

来自分类Dev

PHP PhantomJS在Web服务器上不起作用

来自分类Dev

PHP在Apache服务器上不起作用

来自分类Dev

ZipArchive在服务器php上不起作用

来自分类Dev

PHP包括在Xampp服务器上不起作用

来自分类Dev

PHP 标头在服务器上不起作用?

来自分类Dev

upload.php在我的服务器上不起作用

来自分类Dev

upload.php在我的服务器上不起作用

来自分类Dev

OnClick功能在我的网站上不起作用

来自分类Dev

为什么Laravel邮件在实时服务器上不起作用?

来自分类Dev

使用 PHPmailer 发送邮件在实时服务器上不起作用

来自分类Dev

OpenSSL加密功能在PHP 7.4.5上不起作用

来自分类Dev

该功能在服务器上不起作用。在写上下文中不能使用函数返回值

来自分类Dev

DNS解析在18.04服务器上不起作用

来自分类Dev

uiCulture在服务器上不起作用

来自分类Dev

Rotativa-ViewAspdf在服务器上不起作用

来自分类Dev

速记数组在服务器上不起作用

来自分类Dev

转到:http服务器在osx上不起作用

来自分类Dev

RequiredFieldValidator在服务器上不起作用

来自分类Dev

Codeigniter路由在ubuntu服务器上不起作用

来自分类Dev

导出到Excel在服务器上不起作用

来自分类Dev

DNS解析在18.04服务器上不起作用

Related 相关文章

热门标签

归档