【问题标题】:Form is been redirected to the correct 2nd page but i don't receive the info in emails where is sent to [duplicate]表单被重定向到正确的第二页,但我没有收到发送到 [重复] 的电子邮件中的信息
【发布时间】:2015-08-12 10:09:29
【问题描述】:

我有一个名为 formulario.html 的 html 表单,当他提交并成功时,它会重定向到名为 agradecimentos.html 的第二个页面。 一切进展顺利,但我没有收到他发送到的 2 封电子邮件中表格中的信息。 提前感谢您的帮助。

这是 formulario.html 代码的一部分:

<form action="suporte_email.php" method="post" name="formulario" id="formulario" >

<!-- THAT'S TOO MUCH CODE BUT I CHECKED THAT AND IT SEEMS NOT TO BE WRONG -->

<input type="submit" name="submit" class="button" value="Enviar" />
</form>

agradecimentos.html 是一个简单的 html 代码,我在其中将客户端重定向到该站点的页面。

我的 .php 代码被命名为 suporte_email.php,就像您可以看到操作在哪里一样。我的问题是我没有收到表单中的信息,我仍然不知道我的错误在哪里。

suporte_email.php

<?php
$crlf = "\r\n";
//Get Data
    $nome = $_POST['nome'];                    
    $empresa = $_POST['empresa'];              
    $contacto = $_POST['contacto'];            
    $email = $_POST['email'];                  
    $marca = $_POST['marca'];                   
    $other = $_POST['other'];                    
    $serial_number = $_POST['serial_number'];     
    $garantia = $_POST['garantia'];               
    $contrato = $_POST['contrato'];             
    $permissoes = $_POST['permissoes'];           
    $descricao_avaria = $_POST['descricao_avaria'];
    $checkbox = $_POST["checkbox"];
    $radio = $_POST["radio"];

 // Parse/Format/Verify Data
       $to      = "teste@teste.pt, $email"; 
       $from    = "Suporte";
       $subject = "Formulário de Suporte";

       $email_body = "$crlf De: $nome$crlf Email: $email$crlf Assunto: $subject$crlf$crlf Empresa: $empresa$crlf Contacto: $contacto$crlf Marca: $marca$crlf Outra: $other$crlf Número de Série: $serial_number$crlf Garantia: $radio$crlf Contrato: $checkbox$crlf Tipo de Suporte: $permissoes$crlf$crlf Descrição da Avaria: $descricao_avaria";

       // Setup EMAIL headers, particularly to support UTF-8
       // We set the EMAIL headers here, these will be sent out with your message
       // for the receiving email client to use.
       $headers ='From: '.$to . $crlf . 
                  'Reply-To: ' .$to  . $crlf . 
                  'Content-Type: text/plain; charset=UTF-8' .  $crlf .
                  'X-Mailer: PHP/' . phpversion();



       // Then we pass the headers into our mail function
       mail($to, $from, $subject, $email_body, $headers);
       header('Location: agradecimentos.html');
?>

//Garantia 是一个单选按钮,Contrato 是一个复选框。

【问题讨论】:

  • 您的系统上有邮件服务器吗? mail() 返回一个状态,老实说它没有多大用处,但看看它是个好主意,如果它返回 false 可能会输出错误
  • 另外,您正在对您的邮件发送进行零错误检查。
  • 是的,我有一个邮件服务器@RiggsFolly 好的.. 但它仍然会发生相同的情况,信息不会被发送
  • 哼.. 你有什么建议让它工作@Epodax? :)
  • 和一个简单的邮件呼叫工作?即:mail('teste@teste.pt', 'My Subject', 'testing 1-2-3');

标签: php html forms email


【解决方案1】:

你的

 mail($to, $from, $subject, $email_body, $headers);

应该是

 mail($to, $subject, $email_body, $headers);

mail(to,subject,message,headers,parameters);
PHP mail() Function

添加FromCc 选项应该是

$headers = "From: webmaster@example.com" . "\r\n" .
           "CC: somebodyelse@example.com";

添加html版本应该是这样的

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

编辑 01

        $email_body = "De: $nome
        \r\n Email: $email
        \r\n Assunto: $subject
        \r\n Empresa: $empresa
        \r\n Contacto: $contacto
        \r\n Marca: $marca
        \r\n Outra: $other
        \r\n Número de Série: $serial_number
        \r\n Garantia: $radio
        \r\n Contrato: $checkbox
        \r\n Tipo de Suporte: $permissoes
        \r\n Descrição da Avaria: $descricao_avaria";

【讨论】:

  • 我试过了,但我的电子邮件中仍然没有收到信息
  • 信息表示$email_body内容??
  • $crlf 中有什么内容??
  • 对不起,信息是我在表格中输入的所有信息。表格中的所有信息都应该在一封电子邮件中收到,用 php 编码,它是 $email_body @Abdulla。 $crlf = "\n";
  • 谢谢@Abdulla 改变了这一点,但我仍然没有在我的电子邮件中收到 $email_body 发送时
猜你喜欢
  • 2018-02-12
  • 1970-01-01
  • 1970-01-01
  • 2017-05-03
  • 1970-01-01
  • 2016-01-08
  • 1970-01-01
  • 2018-06-01
  • 1970-01-01
相关资源
最近更新 更多