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 :-/