简体   繁体   English

PHP电子邮件表单未添加提交到我的收件箱的电子邮件

[英]PHP email form is not adding the email submitted to my inbox

For some reason when I submit an email in the form on the site I do not see it show up in my inbox it just says "Email:" with no email address added??! 由于某些原因,当我在网站上的表单中提交电子邮件时,我看不到它显示在我的收件箱中,只是显示“电子邮件:”,而未添加电子邮件地址? HELP 救命

HTML HTML

 <form method="POST" action="/subscribe.php">
      <input type="email" placeholder="Email" name="email">
      <input type="submit" value="submit" name="submit">
    </form>

That's my PHP Code: 那是我的PHP代码:

<?php

## CONFIG ##

# LIST EMAIL ADDRESS
$recipient = "domaininfo@gmail.com";

# SUBJECT (Subscribe/Remove)
$subject = "Notify me when you launch";

# RESULT PAGE
$location = "http://apple.com";

## FORM VALUES ##

# SENDER - WE ALSO USE THE RECIPIENT AS SENDER
# DON'T INCLUDE UNFILTERED USER INPUT IN THE MAIL HEADER!
# SEE ALSO: How to protect a php Email Form using php mail or mb_send_mail against Mail Header Injection
$sender = $recipient;

# MAIL BODY
$body .= "Name: ".$_REQUEST['Name']." \n";
$body .= "Email: ".$_REQUEST['Email']." \n";
# add more fields here if required

## SEND MESSGAE ##

mail( $recipient, $subject, $body, "From: $sender" ) or die ("Mail could not be sent.");

## SHOW RESULT PAGE ##

header( "Location: $location" );
?>

You can't mix cases 你不能混用案件

$_REQUEST['Email'] != $_REQUEST['email']

so change the name on your input or change your request. 因此请更改您输入的名称或更改您的请求。

<input type="email" placeholder="Email" name="Email"> -or- $_REQUEST['email'] <input type="email" placeholder="Email" name="Email"> -或者- $_REQUEST['email']

Even after ignoring many syntax errors such as: 即使忽略了许多语法错误,例如:

  1. Using wrong keys in $_REQUEST, the name of the fields for email is in lower case, hence in handling PHP script also it should be in lowercase. 在$ _REQUEST中使用错误的键,电子邮件的字段名称是小写的,因此在处理PHP脚本时,它也应该是小写的。

  2. There is no feild called Name in the form, but you are using it in PHP code which is handling your script. 表单中没有名为Name的领域,但是您正在处理脚本的PHP代码中使用它。

  3. You should check wheather the form is submitted or not, you may do so as: 您应该检查是否已提交表格,可以这样进行:

     if( isset($_POST['submit']) ) { //Code for handling } 

There could me many things which could be going wrong to list some: 我可能会列举许多可能出错的东西:

  1. Since you are sending Email from a local machine/some server; 由于您是从本地计算机/某些服务器发送电子邮件; most probably it will be treated as a SPAM, may be you would like to take a look into your Junk/Spam folder. 最有可能将其视为垃圾邮件,也许您想查看一下“垃圾邮件/垃圾邮件”文件夹。

  2. You don not have any SMTP server installed(or working) on the machine where you are hosting your scripts. 您在托管脚本的计算机上没有安装(或正在运行)任何SMTP服务器。

Don't mix case letters 请勿混用大小写字母

$_REQUEST['Email'] !=  $_REQUEST['email']

so change name on your input or change your request. 因此,请在输入中更改名称或更改您的请求。

<input type="email" placeholder="Email" name="Email"> -or- $_REQUEST['email']

via http://itspiders.net 通过http://itspiders.net

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

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