Automated emails from Perl script to Outlook and Gmail being discarded

GoWilkes

Well-Known Member
Sep 26, 2006
692
33
178
cPanel Access Level
Root Administrator
This is a growing problem on my end, and I'm at a loss on how to fix it.

I've had three people report this same problem with Outlook.com, and today someone from Gmail had the same problem.

I have a simple form on my site when users forget their password; they enter their username, it emails the password to them through a Perl script.

Gmail and Yahoo have always sent these to spam, which sucks. But now it looks like Outlook and Gmail are just denying them altogether; I don't get a bounce message, but they don't show up in spam folders or anything, either.

In /var/log/exim_mainlog, it looks like the email is being delivered:

Code:
2017-07-21 04:42:55 1dYTWR-0002sC-Dq <= [email protected]_name.example.com U=account_username P=local S=624 T="xxxx User Information" for [email protected] [email protected]
2017-07-21 04:42:55 1dYTWR-0002sC-Dq SMTP connection outbound 1500626575 1dYTWR-0002sC-Dq example.com [email protected]
2017-07-21 04:43:00 1dYTWR-0002sC-Dq => [email protected] R=lookuphost T=remote_smtp H=gmail-smtp-in.l.google.com [209.85.232.27] X=TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128 CV=yes C="250 2.0.0 OK 1500626581 p188si3454800qkc.290 - gsmtp"
The script that I'm using is pretty simple:

Code:
open (MAIL, "|/usr/sbin/sendmail -t") || die "Can't open /usr/sbin/sendmail\n";
print MAIL "To: $to\n";
print MAIL "From: $from ($title)\n";
print MAIL "Subject: $title User Information\n\n";

print MAIL $body;
close (MAIL);
Any suggestions? Do I need to modify the SPF filter, modify the Perl script to include message headers... something else?
 

SysSachin

Well-Known Member
Aug 23, 2015
604
49
28
India
cPanel Access Level
Root Administrator
Twitter
Hi,

Might be your firewall or your ISP blocking outgoing connections to SMTP port.
Can you please try to disabling firewall from your server.
 

Jcats

Well-Known Member
PartnerNOC
May 25, 2011
807
160
168
New Jersey
cPanel Access Level
DataCenter Provider
I've never seen an instance where the email was accepted and queued by Gmail which is what those logs indicate and then just simply discarded(outside of it being a filter setup by the gmail account itself). Gmail will always, always, provide a bounceback if the email is rejected.

Try using the search in Gmail at the top for your server hostname as that is where the email would be coming from, its possible it landed in the promotions box as an example.

Ultimately, you will want to switch to using SMTP authentication to ensure the best mail delivery results.
 
  • Like
Reactions: rpvw

mtindor

Well-Known Member
Sep 14, 2004
1,497
130
193
inside a catfish
cPanel Access Level
Root Administrator
You absolutely either want to use SMTP Authentication (so that, assuming DKIM is enabled and you have a valid SPF record in place), your emails will be DKIM signed and will pass SPF. You can also do that via your PERL script (the DKIM signing) I imagine, but I couldn't tell you how to do it.

All emails should always be DKIM signed and pass SPF for the most reliable delivery.


mike
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463

GoWilkes

Well-Known Member
Sep 26, 2006
692
33
178
cPanel Access Level
Root Administrator
Sorry for the late reply, I've been working on option after option for this...

I finally began using the Perl module Net::SMTPS, which allows an email authentication. The script looks like this:

Code:
use Net::SMTPS;

my $smtp = Net::SMTPS->new(
    "mail.example.com",
    Hello => 'server.example.com',
    Port => 587,
    doSSL => 'starttls'
) or die "Couldn't connect to SMTP server: $1";

$smtp->auth('[email protected]','password');

$smtp->mail('[email protected]');
$smtp->to('[email protected]');

$smtp->data;
$smtp->datasend("From: me\@example.com (Example)\n");
$smtp->datasend("To: me\@gmail.com\n");
$smtp->datasend("Reply-to: me\@example.com\n");
$smtp->datasend("Subject: Test Email\n");
$smtp->datasend("\n");

$smtp->datasend("A simple test message\n");

$smtp->dataend;
$smtp->quit;
That's pretty much an exact copy and paste, other than changing the actual domain to example.com, and of course removing the username and password.

The email goes through now without being discarded, so I'm guessing that the problem was the lack of authentication, after all. But Hotmail still bounces it (stating that the IP range is blacklisted, but my server provider can't find where), and Gmail now sends it to spam.

I've had this server for several years, and it has NEVER been used for spam and never had a virus. All accounts on it belong to me, so I'm positive about that. I have an SPF, DKIM, and DMARC on the account, MXToolbox confirms that I'm on no blacklists, and the Senderbase reputation is "neutral" (per the links from Michael's post above). So I'm at a loss as to why it's being filtered.
 

Jcats

Well-Known Member
PartnerNOC
May 25, 2011
807
160
168
New Jersey
cPanel Access Level
DataCenter Provider
Hotmail keeps their own blacklists so using the online tools like mxtoolbox will do you no good.

You've had the server for several years and haven't had an issue but all of a sudden you are going to spam and are on a blacklist so this would indicate that it has indeed been clean all these years but doesn't mean its clean as of recent.

Can you provide the bounceback you are getting from hotmail?

As far as gmail, they usually indicate why its going into spam, if you go into your spambox, click the email, it will say something like this at the top:

"Why is this message in Spam? It is in violation of Google's recommended email sender guidelines. Learn more"

What does it say?
 

GoWilkes

Well-Known Member
Sep 26, 2006
692
33
178
cPanel Access Level
Root Administrator
I learned that about Hotmail's blacklist just recently myself, jcats. They allegedly have a form to request removal, but it's been broken for the last 2 days, and I don't know any other way to contact them:

https://support.live.com/eform.aspx?productKey=edfsmsbl3&ct=eformts&scrx=1

I just checked SenderScore.org, and I have a 100 reputation there, too. So I can't imagine why Hotmail has a problem.

Here's the bounceback I'm getting:

Code:
This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

  [recipient]@hotmail.com
   host mx3.hotmail.com [65.55.37.104]
   SMTP error from remote mail server after pipelined MAIL FROM:<[email protected][example].com> SIZE=1388:
   550 SC-001 (COL004-MC3F24) Unfortunately, messages from [123.45.67.89] weren't sent. Please contact your Internet service provider since part of their network is on our block list. You can also refer your provider to http://mail.live.com/mail/troubleshooting.aspx#errors.


Reporting-MTA: dns; [server.example.com]

Action: failed
Final-Recipient: rfc822;[recipient]@hotmail.com
Status: 5.0.0
Remote-MTA: dns; mx3.hotmail.com
Diagnostic-Code: smtp; 550 SC-001 (COL004-MC3F24) Unfortunately, messages from [123.45.67.89] weren't sent. Please contact your Internet service provider since part of their network is on our block list. You can also refer your provider to http://mail.live.com/mail/troubleshooting.aspx#errors.
(Sections in brackets were changed by me, of course)

Gmail is a bit more vague, it just says:

Code:
Why is this message in Spam? It's similar to messages that were detected by our spam filters.
I've tried both the exact message I posted earlier ("A simple test message") and a legit email with the user's username and password (that I've been sending for close to 15 years), and both had the same vague explanation.
 

Jcats

Well-Known Member
PartnerNOC
May 25, 2011
807
160
168
New Jersey
cPanel Access Level
DataCenter Provider
Ah its possible there are abusers, not on your specific IP but within the /24

What if you go to senderbase and do search reputation for 123.45.67.89/24

Are there any poor rated? This could be affecting you.
 

GoWilkes

Well-Known Member
Sep 26, 2006
692
33
178
cPanel Access Level
Root Administrator
Thanks for the tip :) In the /24, there are 3 servers listed, including mine. All 3 have a neutral reputation, and are on no blacklists. The first server has a "Last Month Volume" of 1.7, the other two (including mine) are 1.3.

So, good thought! But these look OK, too.

Looking at /20, there are 56 servers listed: 3 of them have a "poor" reputation, and 11 are "good". Would those negatives affect me at that wide of a range?
 

GoWilkes

Well-Known Member
Sep 26, 2006
692
33
178
cPanel Access Level
Root Administrator
Just to further update, I used mail-tester.com to ensure that the email has a good rating. It suggest that I add a "Date" and "Message-ID" header to the script, and now it has a perfect 10/10 score with a SpamAssassin score of +0.1.

But still, Gmail sends it to spam, and Hotmail bounces it :'-(

"Original message" link from Gmail says:

Code:
Message ID <[email protected]>
Created at: Tue, Jul 25, 2017 at 4:13 PM (Delivered after 1 seconds)
From: [Me]<[email protected][example].com>
To: [me]@gmail.com
Subject: Test Email
SPF: PASS with IP [123.45.67.89] Learn more
DKIM: PASS with domain [example].com Learn more
DMARC: PASS
 

GoWilkes

Well-Known Member
Sep 26, 2006
692
33
178
cPanel Access Level
Root Administrator
Thanks, Michael, I just submitted a request to Microsoft.

I can't find a support form to Gmail, but I did find this:

Sign in - Google Accounts

There's a theory that it might help, but I guess we'll see! I'm waiting for them to recognize the TXT that I added to my DNS, so hopefully I'll know more tomorrow.