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

Asked

Viewed 114 times

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");
  • How do you know the email was sent? by echo?

  • Ever tried using Phpmailer or Swiftmailer? These are libraries where you set up an email account and use it to send.

  • @rray I don’t know that was just for me to know if php was running

1 answer

1


Try to use this version more complete and check if it resolves. Whenever I use the form I posted below, all servers receive 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 );

?>
  • for outlook still not working

  • It must be your sender that is on some spam list, usually this here solves my spam problems

  • Since the email was recent the outlook won’t let it work so just send an outlook email to an email on the server to unblock it Thank you :)

Browser other questions tagged

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