简体   繁体   English

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

[英]NO Email is sending in php even in Spam nor Inbox

What I need: 我需要的:

  • when i submit a form mail is sended to recipent. 当我提交表格邮件时,将其发送给菜谱师。

My Problem : 我的问题 :

  • when submit form , form is Submitted ok with Reponse code:200k but no email is delivered. 当提交表单时,表单已提交,响应码:200k,但未发送电子邮件。

here my code that im using:- 这是我正在使用的代码:-

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>

Error log: 错误日志:

  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

installing send mail: 安装发送邮件:

    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

Look like you haven't can a program installed that php can use to send email. 看起来您尚未安装php可以用来发送电子邮件的程序。

Install Sendmail 安装Sendmail

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM