Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php发送欢迎电子邮件和重定向页面_Php_Email - Fatal编程技术网

如何使用php发送欢迎电子邮件和重定向页面

如何使用php发送欢迎电子邮件和重定向页面,php,email,Php,Email,目前,我有下面的代码,它将html输入字段(电子邮件)的内容发送到welcome@domain.com地址。有两件事我现在正在努力解决。我使用了以下代码位,但毫无用处- $to = "welcome@domain.com"; $headers = "From: $email_from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to,$email_subject,$email_body,$headers); //done.

目前,我有下面的代码,它将html输入字段(电子邮件)的内容发送到welcome@domain.com地址。有两件事我现在正在努力解决。我使用了以下代码位,但毫无用处-

$to = "welcome@domain.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";

mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: thankyou.html');
  • 我如何从自动发送电子邮件回复welcome@domain.com?

  • 有没有办法将他们重定向到domain.com/thankyou.html,而不是在页面上说“谢谢您与我们联系,我们很快就会联系”呢

  • 这是代码的其余部分,似乎运行良好!如果对此有任何建议,尽管它们总是非常受欢迎

    if(isset($_POST['email'])) {
    
    $email_to = "welcome@domain.com";
    $email_subject = "Your spot has been saved!";
    function died($error) {
    
    
    echo "We are very sorry, but there were error(s) found with the form your submitted";
    echo "These errors appear below<br /><br />";
    echo $error."<br /><br />";
    echo "Please go back and fix these errors<br /><br />";
    die();
    }
    
    
    if(
    !isset($_POST['email'])
    ) {
    died("We are sorry, but there appears to be a problem with the form your submitted!");
    }
    $email_from = $_POST['email']; 
    $error_message = "";
    $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
    if(!eregi($email_exp,$email_from)) {
    $error_message .= "The Email Address you entered does not appear to be valid!<br />";
    }
    if(strlen($error_message) > 0) {
    died($error_message);
    }
    $email_message = "Form details below.\n\n";
    function clean_string($string) {
    $bad = array("content-type","bcc:","to:","cc:","href");
    return str_replace($bad,"",$string);
    }
    $email_message .= 'Email: '.clean_string($email_from)."\n";
    
    $headers = 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
    @mail($email_to, $email_subject, $email_message, $headers);
    ?>
    Thank you for contacting us. We will be in touch with you very soon.
    <?
    }
    ?>
    
    if(设置($\u POST['email'])){
    $email_to=”welcome@domain.com";
    $email\u subject=“您的位置已保存!”;
    函数失效($error){
    echo“非常抱歉,您提交的表单存在错误”;
    echo“这些错误出现在下面

    ”; echo$错误。“

    ”; echo“请返回并修复这些错误

    ”; 模具(); } 如果( !isset($\u POST['email']) ) { 死亡(“很抱歉,您提交的表单似乎有问题!”); } $email\u from=$\u POST['email']; $error_message=“”; $email_exp=“^[A-Z0-9.\%-]+@[A-Z0-9.-]+\[A-Z]{2,4}$”; 如果(!eregi($email\u exp,$email\u from)){ $error_message.=“您输入的电子邮件地址似乎无效!
    ”; } 如果(strlen($error_message)>0){ 死亡($error_message); } $email\u message=“下面的表单详细信息。\n\n”; 函数clean_string($string){ $bad=数组(“内容类型”,“密件抄送:”、“收件人:”、“抄送:”、“href”); 返回str_replace($bad,“,$string); } $email\u message.='email:'。清除字符串($email\u from)。“\n”; $headers='From:'.$email\u From.\r\n。 '回复:'.$email\u from.\r\n'。 'X-Mailer:PHP/'.phpversion(); @邮件($email\u to、$email\u subject、$email\u message、$headers); ?> 感谢您联系我们。我们将很快与您联系。
    有关未重定向页面的信息,请参阅本文stackoverflow.com/questions/6396813/php-header-not-redirecting 它基本上说,在头调用之前,不能向流输出任何值


    对于邮件问题,请详细说明您遇到的错误。

    您现有的代码有什么问题?是否会显示错误消息?是否未发送电子邮件?是否将电子邮件发送到错误的地址?您好,andrewsi,表单会将初始电子邮件发送到welcome@domain.com没有显示错误,页面只显示“感谢您联系我们,我们将我很快就会与你联系。回信没有发送,据我所知,它没有发送到错误的地址,只是根本没有发送。你应该从第二次
    邮件
    呼叫中删除“@”前缀,否则它将抑制错误消息()!