The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Automated emails from Perl script to Outlook and Gmail being discarded

Discussion in 'E-mail Discussions' started by GoWilkes, Jul 21, 2017.

  1. GoWilkes

    GoWilkes Well-Known Member

    Joined:
    Sep 26, 2006
    Messages:
    395
    Likes Received:
    5
    Trophy Points:
    168
    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 <= 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:

    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?
     
  2. SysSachin

    SysSachin Well-Known Member

    Joined:
    Aug 23, 2015
    Messages:
    543
    Likes Received:
    39
    Trophy Points:
    28
    Location:
    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.
     
  3. Jcats

    Jcats Well-Known Member

    Joined:
    May 25, 2011
    Messages:
    588
    Likes Received:
    88
    Trophy Points:
    153
    Location:
    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.
     
    rpvw likes this.
  4. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,301
    Likes Received:
    42
    Trophy Points:
    178
    Location:
    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
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,171
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
  6. GoWilkes

    GoWilkes Well-Known Member

    Joined:
    Sep 26, 2006
    Messages:
    395
    Likes Received:
    5
    Trophy Points:
    168
    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('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.
     
  7. Jcats

    Jcats Well-Known Member

    Joined:
    May 25, 2011
    Messages:
    588
    Likes Received:
    88
    Trophy Points:
    153
    Location:
    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?
     
  8. GoWilkes

    GoWilkes Well-Known Member

    Joined:
    Sep 26, 2006
    Messages:
    395
    Likes Received:
    5
    Trophy Points:
    168
    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:<info@[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.
     
  9. Jcats

    Jcats Well-Known Member

    Joined:
    May 25, 2011
    Messages:
    588
    Likes Received:
    88
    Trophy Points:
    153
    Location:
    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.
     
  10. GoWilkes

    GoWilkes Well-Known Member

    Joined:
    Sep 26, 2006
    Messages:
    395
    Likes Received:
    5
    Trophy Points:
    168
    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?
     
  11. GoWilkes

    GoWilkes Well-Known Member

    Joined:
    Sep 26, 2006
    Messages:
    395
    Likes Received:
    5
    Trophy Points:
    168
    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 <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]<info@[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
     
  12. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,171
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
  13. GoWilkes

    GoWilkes Well-Known Member

    Joined:
    Sep 26, 2006
    Messages:
    395
    Likes Received:
    5
    Trophy Points:
    168
    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.
     
  14. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,171
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page