Automated emails from Perl script to Outlook and Gmail being discarded
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:
The script that I'm using is pretty simple:
Any suggestions? Do I need to modify the SPF filter, modify the Perl script to include message headers... something else?
2017-07-21 04:42:55 1dYTWR-0002sC-Dq <= xxxx@server_name.example.com U=account_username P=local S=624 T="xxxx User Information" for recipient@gmail.com my_username@example.com
2017-07-21 04:42:55 1dYTWR-0002sC-Dq SMTP connection outbound 1500626575 1dYTWR-0002sC-Dq example.com recipient@gmail.com
2017-07-21 04:43:00 1dYTWR-0002sC-Dq => recipient@gmail.com 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:
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?
-
Hi, Might be your firewall or your ISP blocking outgoing connections to SMTP port. Can you please try to disabling firewall from your server. 0 -
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. 0 -
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 0 -
Hello, The previous post is correct. You'd need to setup your form to use SMTP authentication to help prevent the email from going to the SPAM folder. The following document may also help: How to Keep your Email out of the Spam Folder - cPanel Knowledge Base - cPanel Documentation Thank you. 0 -
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: 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('username@example.com','password'); $smtp->mail('me@example.com'); $smtp->to('me@gmail.com'); $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.0 -
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? 0 -
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. 0 -
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? 0 -
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: Message ID <5977a676.b321ed0a.d9864.1f53SMTPIN_ADDED_BROKEN@mx.google.com> Created at: Tue, Jul 25, 2017 at 4:13 PM (Delivered after 1 seconds) From: [Me] 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: PASS0 -
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. 0 -
Here's the link you can use for Gmail: Troubleshooting for bulk email senders - Gmail Help Thank you. 0
Please sign in to leave a comment.
Comments
13 comments