【问题标题】:NO Email is sending in php even in Spam nor Inbox即使在垃圾邮件或收件箱中,也没有电子邮件以 php 发送
【发布时间】:2014-06-10 14:13:20
【问题描述】:

我需要什么:

  • 当我提交表单时,邮件会发送给recipent。

我的问题:

  • 提交表单时,表单提交正常,响应代码:200k,但未发送电子邮件。

这是我正在使用的代码:-

if(isset($_POST['submit']))
{
    $to = $_POST['email'];
    $from = "abc@gmail.com";
    $subject = "subject";
    $message = "<div style=\"background:red;height:100px;width:100px;display:block;\">dfsdf</div>";
    $headers = "MIME-Version: 1.0 \r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";
    $headers  .= "From: $from\r\n";
    mail($to, $subject, $message, $headers);
    echo "Message has been sent....!";  
 }else{
    echo "Add an email address"; 
 }?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="testemail.php" method="post">
  <input name="email" type="text" />
  <input name="submit" type="submit" value="Submit">
</form>
</body>
</html>

错误日志:

  HP Notice:  Undefined variable: form in /var/www/index2.php on line 192
[Tue Jun 10 19:09:10.799088 2014] [:error] [pid 3588] [client 127.0.0.1:48078] PHP  Notice:    Undefined index: WRCF-Name in /var/www/asana/index2.php on line 246
[Tue Jun 10 19:09:10.799095 2014] [:error] [pid 3588] [client 127.0.0.1:48078] PHP Notice:    Undefined index: WRCF-Email in /var/www/asana/index2.php on line 251
[Tue Jun 10 19:09:37.272245 2014] [:error] [pid 3545] [client 127.0.0.1:48096] PHP Notice:   Undefined index: save-stuff in /var/www/asana/index2.php on line 123, referer: http://localhost/index2.php

sh: 1: /usr/sbin/sendmail: not found
sh: 1: /usr/sbin/sendmail: not found
sh: 1: /usr/sbin/sendmail: not found
sh: 1: /usr/sbin/sendmail: not found
sh: 1: /usr/sbin/sendmail: not found
sh: 1: /usr/sbin/sendmail: not found

安装发送邮件:

    sudo apt-get install sendmail
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    sendmail is already the newest version.
    The following packages were automatically installed and are no longer required:
    libfluidsynth1 libmad0 libmikmod2 libsdl-image1.2 libsdl-mixer1.2
    libsdl1.2debian libwebp4 linux-headers-3.11.0-19
    linux-headers-3.11.0-19-generic linux-image-3.11.0-19-generic
    linux-image-extra-3.11.0-19-generic musescore-soundfont-gm sauerbraten-data

【问题讨论】:

  • 你的邮件服务器日志告诉你什么?
  • 检查日志并尝试 phpMailer 库
  • 从本地机器发送这个?还是来自服务器?
  • 本地 Smtp 或 senmail 是否安装在您正在测试的环境中?
  • 您没有安装本地邮件服务器。即使不是 sendmail,其他“大”的(postfix、exim 等)也会创建一个 sendmail 符号链接。因为你根本没有 sendmail,所以你没有安装任何邮件服务器。

标签: php email


【解决方案1】:

看起来你还没有安装 php 可以用来发送电子邮件的程序。

安装 Sendmail

【讨论】:

  • 这可能会有所帮助:stackoverflow.com/questions/4963688/… 基本上你不应该真正使用 php 邮件功能,因为它可能非常不安全。最好使用具有自己发送电子邮件方式的现有库。
  • 仍然支持,因为安装 sendmail 可以暂时解决问题。
  • 我已经在我的本地主机上安装了发送邮件服务器,即使它不工作
  • 你是如何安装 sendmail 的?你用的是什么口味的操作系统?
猜你喜欢
  • 1970-01-01
  • 2021-03-09
  • 2018-03-16
  • 2011-10-28
  • 2013-10-17
  • 1970-01-01
  • 1970-01-01
  • 2017-04-27
  • 2017-05-12
相关资源
最近更新 更多