没有电子邮件即使在垃圾邮件或收件箱中也在发送

时间:2014-06-10 14:13:21

标签: php email

我需要什么:

  • 当我提交表格邮件时,发送给食谱。

我的问题:

  • 提交表单时,表单已提交确认,回复代码: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

1 个答案:

答案 0 :(得分:1)

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

安装Sendmail