本文介绍了将表单提交到电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试输入电子邮件地址发送到我的收件箱,以便当用户以形式输入他的电子邮件时,我会收到一封电子邮件通知。
I'm trying to have entered email address delivered to my inbox so that when user enters his email in form, I get an email notification about it.
是php:
<?php
if($_POST){
$email = $_POST['email'];
//send email
mail("[email protected]", "Newsletter Signup:" .$email);
}
?>
我在做什么错,因为它不工作atm?
What am I doing wrong since it's not working atm ?
推荐答案
这个问题有什么问题
不能交付任何东西都可以 。检查邮件服务器和网络服务器的环境。
The reason why your mails won't be delivered can be really anything. Check the environments of your mailserver and your webserver.
- 检查您的电子邮件帐户是否有垃圾邮件过滤器
- 或许您的互联网提供商因为未经验证的发件人地址阻止电子邮件
- 防火墙问题
- 等...
- Check your Email Account for spam filters
- Maybe your internet provider is blocking the email because of unverified sender address
- Firewalls problems
- etc...
如何解决问题
由于php中的mail()函数实现正在返回一个布尔值,您可以使用此返回值来检测错误:
Since the mail() function implementation in php is returning a boolean, you can use this return value to detect an error:
<?php [...]
$email = $_POST['email'];
$success = mail("[email protected]", "Newsletter Signup:", $email);
if (!$success) {
$error = error_get_last();
var_export($error);
}
[...] ?>
也许这将有助于您找到问题。
Maybe this will help you to locate the problem.
这篇关于将表单提交到电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!