Forum Moderators: coopster & phranque

Message Too Old, No Replies

Sending email without using sendmail

         

csdude55

7:20 pm on Mar 3, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It recently came to my attention that plain text emails being sent through sendmail are being rejected by Gmail, possibly others. So I have 100+ scripts that are not functioning like they used to :-(

This:

open MAIL,"|/usr/sbin/sendmail -t";
print MAIL "To: whatever@gmail.com\n";
print MAIL "From: any@address.com (Lorem Ipsum)\n";
print MAIL "Subject: Foo\n\n";

print MAIL $body;
close (MAIL);


results in this:

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:

client_email@his_domain.com
(generated from client_email@his_domain.com)
host gmail-smtp-in.l.google.com [142.250.115.26]
SMTP error from remote mail server after end of data:
550-5.7.26 Unauthenticated email from his_domain.com is not accepted due to domain's
550-5.7.26 DMARC policy. Please contact the administrator of yahoo.com domain
550-5.7.26 if this was a legitimate mail. Please visit
550-5.7.26 [support.google.com...] to learn about the
550 5.7.26 DMARC initiative. b24si10524548oob.80 - gsmtp


I asked about the error on the cPanel forum, and the only solution offered was the /sendmail bypasses DMARC and DKIM. Which means that, in order to have these emails delivered, I'm going to have to modify every one of my scripts :-O

The first and simplest solution appeared to be this:

use MIME::Lite;
use Net::SMTP;

my $host = 'mail.domain.com';
my $user = 'user@domain.com';
my $pass = 'password1234';

# I'm totally guessing on plugging in SSL and Port here
MIME::Lite->send('smtp', $host, AuthUser => $user, AuthPass => $pass, SSL => 1, Port => 465);

my $msg = MIME::Lite->new(
From => any@address.com,
To => whatever@gmail.com,
Subject => 'Foo',
Type => 'text/plain; charset=UTF-8',
Encoding => 'quoted-printable',
Data => $body
);
$msg->send;


Before I go through all of the scripts, do you guys and gals think this is the BEST way to do it? I'd really hate to spend the next month working on this, just to find out that there's a new security thing or something coming up that will make me start over :-/

JorgeV

7:49 pm on Mar 3, 2021 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



Hello,

You do not need to go through your scripts.

- DMARC is a record which needs to be added to the DNS

- DKIM is added on the fly by Sendmail to each outgoing emails. Look for opendkim, sendmail and the name of your OS for the instructions on how to configure all this to work together.

csdude55

9:02 pm on Mar 3, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Everything SEEMS fine on a DNS level:

# changed the IP for this post, of course
his_domain.com. 14400 IN TXT "v=spf1 +a +mx +ip4:123.45.67.89 ~all"

default._domainkey 14400 IN TXT "v=DKIM1; k=rsa; p=[key]\;

_dmarc 14400 IN TXT "v=DMARC1;p=reject;sp=reject;adkim=r;aspf=r;pct=100;fo=0;rf=afrf;ri=86400;rua=mailto:hostmaster@mydomain.com;ruf=mailto:hostmaster@mydomain.com"


MXToolbox shows no problems, but Gmail still rejects them. This is why the folk on the cPanel forum blame sendmail :-/

csdude55

9:21 pm on Mar 3, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Minor update, apparently MIME::Lite isn't recommended by the author anymore:

[metacpan.org...]

So if I DO need to rewrite, then the example I gave before is trash... :-/

phranque

9:55 pm on Mar 3, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i would go through Google's documented process to Troubleshoot DMARC issues [support.google.com] before i would blame sendmail or the perl module you are using.

Brett_Tabke

1:24 am on Mar 4, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



ck dmarc is setup right here: [mxtoolbox.com...]

csdude55

9:24 pm on Mar 4, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's hard to be positive, but using the link @Brett_Tabke gave, the problem MIGHT have been that the "rua" and "ruf" were sending to an email address that's not the same as the source's domain. I changed it last night (maybe 16 hours ago) and so far I haven't had any more problems.

It's too early to say that definitely fixed it, so I'll reply back within a few days with an update.

phranque

10:32 pm on Mar 4, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



the problem MIGHT have been that the "rua" and "ruf" were sending to an email address that's not the same as the source's domain

not likely.

regarding rua (with my emphasis applied):
This option can potentially result in a high volume of report emails. We don’t recommend using your own email address. Instead, consider using a dedicated mailbox, a group, or a third-party service that specializes in DMARC reports.

regarding ruf:
Gmail doesn’t support the ruf tag, ...

source: https://support.google.com/a/answer/2466563#dmarc-record-tags

csdude55

10:55 pm on Mar 4, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Blah. Well, that's the only issue that MXToolbox found :-( Which leads me back to the issue being sendmail. Or, more specifically, Gmail's relationship with emails sent via sendmail.

phranque

12:00 am on Mar 5, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



did you actually follow to completion Gmail's DMARC troubleshooting process i linked to above?

it is more likely that Gmail is rejecting your specific server or domain than it is rejecting (out of hand) a widely used open source mail transfer agent.