Question

I have an application that sends emails daily. I'm using SwiftMailer PHP library and SMTP accounts.

I sent test emails to the following providers to see if emails go to inbox or spam:

 - GMail   (OK - Inbox)
 - Yahoo   (OK - Inbox)
 - AOL     (OK - Inbox)
 - Outlook (FAIL - Junk)

Now the code I use:

    // init smtp transport
    if ($smtp_ssl !== false)
    {
        $transport = Swift_SmtpTransport::newInstance($smtp_host, $smtp_port, strtolower($smtp_ssl));
    }
    else
    {
        $transport = Swift_SmtpTransport::newInstance($smtp_host, $smtp_port);
    }

    // using login/password
    if($smtp_user !== false && $smtp_pass !== false){
        $transport->setUsername($smtp_user);
        $transport->setPassword($smtp_pass);
    }

    $mailer = Swift_Mailer::newInstance($transport);

    $status = $mailer->send($message);

I dont understand why Outlook sees this as a spam.

Now the thing I noticed is that if my SMTP account is from my server like: test@myserverdomain.com goes into spam but if I change my SMTP account to something like test@gmail.com then it goes to inbox.

Could there be something wrong with my server domain that hotmail is treating it as spam?

Also If my SMTP account is test@gmail.com now AOL treats emails sent from this SMTP account as SPAM.

Was it helpful?

Solution

You cannot simply use random mail addresses and hope it works. Spam countermeasures may check whether or not the sending server is actually allowed to send mails from that address. Google about "Domain Keys" or "SPF" to see two existing methods to authenticate the sending of mails. I assume that your server is not allowed to send mails from the "@gmail.com" domain, so anyone is doing the right thing flagging these as spam.

Additionally, spam detection is analyzing the mail contents. And this might also be individually configured, because everyones spam is different. You stating that "outlook.com" recognized your mail as spam might be because you flagged mails as spam earlier that looked just like the one you are sending now. A different account might see this mail as valid.

If the receiving mail service does not inform the recipient about why this mail was flagged as spam, there simply is not very much you can do. But it's not SwiftMailers fault, or related to your setup.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top