Why does gmail get php email and outlook does not receive or send spam?

0
    $to = "[email protected]";
    $subject = "My subject";
    $txt = "Hello world!";

    $email ="[email protected]";
    $headers = "MIME-Version: 1.0\r\n"; 
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "To: <".$to.">\r\n"; 
    $headers .= "From: <".$email.">\r\n";



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

    echo("enviado");
    
asked by anonymous 28.10.2015 / 16:18

1 answer

1

Try to use this more complete version and check if it works. Whenever I use the form I posted below, all servers receive it quietly.

<?php

$subject = 'Assunto';
$from = '[email protected]';
$to = '[email protected]';
$bcc = null; // Esconder endereços de e-mails.
$cc = null; // Qualquer destinatário pode ver os endereços de e-mail especificados nos campos To e Cc.
$message = 'Corpo da mensagem';

$headers = sprintf( 'Date: %s%s', date( "D, d M Y H:i:s O" ), PHP_EOL );
$headers .= sprintf( 'Return-Path: %s%s', $from, PHP_EOL );
$headers .= sprintf( 'To: %s%s', $to, PHP_EOL );
$headers .= sprintf( 'Cc: %s%s', $cc, PHP_EOL );
$headers .= sprintf( 'Bcc: %s%s', $bcc, PHP_EOL );
$headers .= sprintf( 'From: %s%s', $from, PHP_EOL );
$headers .= sprintf( 'Reply-To: %s%s', $from, PHP_EOL );
$headers .= sprintf( 'Message-ID: <%s@%s>%s', md5( uniqid( rand( ), true ) ), $_SERVER[ 'HTTP_HOST' ], PHP_EOL );
$headers .= sprintf( 'X-Priority: %d%s', 3, PHP_EOL );
$headers .= sprintf( 'X-Mailer: PHP/%s%s', phpversion( ), PHP_EOL );
$headers .= sprintf( 'Disposition-Notification-To: %s%s', $from, PHP_EOL );
$headers .= sprintf( 'MIME-Version: 1.0%s', PHP_EOL );
$headers .= sprintf( 'Content-Transfer-Encoding: 8bit%s', PHP_EOL );
$headers .= sprintf( 'Content-Type: text/html; charset="iso-8859-1"%s', PHP_EOL );

mail( null, $subject, $message, $headers );

?>
    
28.10.2015 / 17:34