My form only sends the email to the server itself

Asked

Viewed 61 times

0

I have a form that sends e-mail normally, but when I put the option to send a copy to the customer’s email, it does not send. I did several tests and found that he does not send e-mail to any account that is not from the server itself. That is, I am receiving customer orders, but customers are not receiving a copy, as I should receive. What I do?

$to = $email;
$subject = "Seu pedido ao restaurante BARDANA - Número do Pedido: 00".$gerador;

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

$headers .= "From: $email\r\n"; // remetente
$headers .= 'Cc: [email protected]' . "\r\n";


//mail($to,$subject,$message,$headers);

if(mail($to,$subject,$message,$headers)) {

}

On the part of $to was for him to send a copy to the e-mail registered in the form ($email)

Thank you for your attention!

  • When supplementing a question that has not yielded results, edit it instead of re-asking it. By the way, repeating the comment already made in your original question, you keep not putting the < > missing from email addresses.

  • Hi Bacco, I even tried to delete that question, but I’m new here and I didn’t see how to do it. I put <> but still didn’t send.

  • And the weirdest that in the email that this request will, appears in the header right the client’s email as copy, but that ends up not being sent. :(

  • Since there is no answer there, you can click edit below and add as many details as you need. The very fact of editing brings her back to the queue of posts with activity, attracting more attention. In fact, it does not serve as an answer to the question, but serves as a test: calling the mail function twice, once with each address.

1 answer

0

Try implementing your email triggering system with Phpmailer. After downloading and setting up on your desktop, do something more or less like this to trigger these emails.

<?php

require "../PHPMailerAutoload.php";

// Cria uma noa instância de PHPMailer
$mail = new PHPMailer;
// Dados de Quem envia
$mail->setFrom($email, "Nome de quem envia");
// Se quiser que as respostas sejam enviadas para outro email
$mail->addReplyTo($email, "Responda para");
// Dados de Quem recebe
$mail->addAddress($email);
// Cópia de outro email que receberá
$mail->addCC("[email protected]");
// Assunto da mensagem
$mail->Subject = "Seu pedido ao restaurante BARDANA - Número do Pedido: 00" .$gerador;
// Mensagem do formulário em HTML
$mail->msgHTML("<b>Mensagem de $nome</b><br /><br />$message");
// Mensagem alternativa para leitores de email que não suportam HTML
$mail->AltBody = "Esta mensagem está em HTML, use um leitor de emails compatível.";
// Envia a mensagem e verifica se deu certo
if (!$mail->send()) {
    echo "Deu erro ao enviar: " . $mail->ErrorInfo;
} else {
    echo "Mensagem enviada!";
}

I hope you solve, I hope I’ve helped.

  • I noticed that you use the msgHTML method instead of the Body method for content that contains, or may contain, HTML. I had never seen this method before and I believe that many also do not, because, in Phpmailer’s own Github, they teach using Body and do not make any mention of msgHTML. Could you tell us the difference between the two methods?

  • @Claydersonferreira , in the class that is hosted on Github has the example of how it is in the publication: https://github.com/PHPMailer/PHPMailer/blob/master/examples/sendmail.phps

Browser other questions tagged

You are not signed in. Login or sign up in order to post.