php 命令isset ($_post) 提交命令不发送邮件
php command isset ($_post) submit command not sending email
我下面的代码没有向邮件服务器发送电子邮件以订阅邮件列表,我很困惑为什么它不是 working.Displays 谢谢网页提交后,没有收到列表处理程序发送的任何响应, 如果在电子邮件中手动输入我会收到回复...
<?php
//thanku webpage routine
if (isset($_POST['submit']))
{
?>
<script type="text/javascript">
window.location = "http://www.thankyou web url here ";
</script>
<?php
}
if(isset($_POST['email'])) {
$to = "email address here" ;
$message = "SUBSCRIBE list name" ;
$subject = " ";
$email = $_POST["email"] ;
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
?>
<form class="rform" method="post" action="https://webform web url">
<fieldset><legend><strong>Signup</strong></legend>
<h4> mailing list text here:</h4>
<p><label for="email">Email address:</label> <input title="email address." name="email" type='email' pattern=".+(@tvs.ac.uk)|.+(@tvsa.ac.uk)|.+ (@research.gla.ac.uk)" required />
</p>
<input style="float: right;" type="submit" name="submit" value="Subscribe" /> </fieldset> </form>
不需要重定向 javascript。一旦完成所需的逻辑,也应该进行重定向。试试下面的脚本
<?
if(isset($_POST['email'])) {
$to = "email address here" ;
$message = "SUBSCRIBE list name" ;
$subject = " ";
$email = $_POST["email"] ;
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
header('location:http://www.thankyou web url here');
}
?>
- 检查服务器的 SMTP 设置。 php.ini 中的 SMTP 是否已激活?
- 尝试检查您的服务器日志。它可能会给你更多信息
例如,在我拥有的空白服务器上进行尝试:
PHP Warning: mail(): Failed to connect to mailserver at
"localhost" port 25, verify your "SMTP" and
"smtp_port" setting in php.ini or use ini_set() in
[...]index.php on line 20, referer:
http://localhost/
我下面的代码没有向邮件服务器发送电子邮件以订阅邮件列表,我很困惑为什么它不是 working.Displays 谢谢网页提交后,没有收到列表处理程序发送的任何响应, 如果在电子邮件中手动输入我会收到回复...
<?php
//thanku webpage routine
if (isset($_POST['submit']))
{
?>
<script type="text/javascript">
window.location = "http://www.thankyou web url here ";
</script>
<?php
}
if(isset($_POST['email'])) {
$to = "email address here" ;
$message = "SUBSCRIBE list name" ;
$subject = " ";
$email = $_POST["email"] ;
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
?>
<form class="rform" method="post" action="https://webform web url">
<fieldset><legend><strong>Signup</strong></legend>
<h4> mailing list text here:</h4>
<p><label for="email">Email address:</label> <input title="email address." name="email" type='email' pattern=".+(@tvs.ac.uk)|.+(@tvsa.ac.uk)|.+ (@research.gla.ac.uk)" required />
</p>
<input style="float: right;" type="submit" name="submit" value="Subscribe" /> </fieldset> </form>
不需要重定向 javascript。一旦完成所需的逻辑,也应该进行重定向。试试下面的脚本
<?
if(isset($_POST['email'])) {
$to = "email address here" ;
$message = "SUBSCRIBE list name" ;
$subject = " ";
$email = $_POST["email"] ;
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
header('location:http://www.thankyou web url here');
}
?>
- 检查服务器的 SMTP 设置。 php.ini 中的 SMTP 是否已激活?
- 尝试检查您的服务器日志。它可能会给你更多信息
例如,在我拥有的空白服务器上进行尝试:
PHP Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in [...]index.php on line 20, referer: http://localhost/