PHP sends email, but some providers do not receive

Asked

Viewed 31 times

0

I did the function below, which does not return any error, but also does not arrive in some destination emails (Yahoo for example)

function enviaEmail($titulo = '', $conteudo = '', $email = '', $nome = '') {
  $to      = $email;
  $subject = $titulo;
  $content = Reconstroi($conteudo, $nome);
  $headers = array('Content-Type: text/html; charset=UTF-8');
  $headers[] = 'From: meu site@ <[email protected]>';

  $status  = wp_mail($to, $subject, $content, $headers);
  if($status==TRUE){return 1;}else{return 0; echo"deu erro no envio do email " 
 .$status;}//return var_dump($status);
}

How to get the email to the right destinations?

1 answer

0

I would first try to use a more complete header:

                    $to="[email protected]";
                    $subject="Título da Mensagem";
                    $from = 'Email do Sender <[email protected]>';
                    $body='Hi '.$name.', <br/><br>Now You can See Yor main in inbox';
                    $headers = "From: " .($from) . "\r\n";
                    $headers .= "Reply-To: ".($from) . "\r\n";
                    $headers .= "Return-Path: ".($from) . "\r\n";;
                    $headers .= "MIME-Version: 1.0\r\n";
                    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
                    $headers .= "X-Priority: 3\r\n";
                    $headers .= "X-Mailer: PHP". phpversion() ."\r\n";
                    mail($to,$subject,$body,$headers);

Browser other questions tagged

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