Welcome to WebmasterWorld Guest from 54.172.221.7

Forum Moderators: phranque

A general alert for sendmail users

if your emails aren't being delivered

     
9:39 pm on Dec 13, 2018 (gmt 0)

Senior Member

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

joined:Mar 15, 2013
posts: 997
votes: 95


I've had the same sendmail setup for YEARS with no problems, but I recently noticed that some of my generated emails weren't being delivered. I specifically saw that they weren't being delivered to Gmail because I have all of my emails directed to Gmail, but it could have also been affecting other email providers, too.

It took about 4 days of digging to figure out the problem.

When using sendmail, it's required to have an email address in the From: field; eg:

CSDude <example@example.com>

In my scripts I never forced a return email address; I plugged it in if provided by the user, but if not then the system always plugged in my_server_account@my_server_name.com.

But apparently this is no longer acceptable. I stumbled across this error in my server's delivery report:

ECDHE-RSA-AES128-GCM-SHA256:128 CV=yes: SMTP error from remote mail server after end of data: 550-5.7.1 [123.45.67.89 14] Messages missing a valid address in From:\n550 5.7.1 header, or having no From: header, are not accepted. k8si721600qtj.365 - gsmtp


(where 123.45.67.89 represents my server's IP)

The solution was to simply force a From: email address in all of my scripts. I also used the -f flag, like so:

# Perl (not sure if -tif is the same as -ti -f?
open (MAIL,"|$mailprog -ti -f "example\@example.com");
print MAIL <<EOF;
To: to\@example.com
From: CSDude <example\@example.com>
Subject: the subject
blah blah blah
EOF;
close (MAIL);

# PHP
$to = 'to@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: CSDude <example@example.com>' . "\r\n" .
'Reply-To: example@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers, '-f example@example.com');


And since we're talking about it, here are all of the -options for sendmail:

[commandlinux.com...]
2:56 am on Dec 14, 2018 (gmt 0)

Senior Member

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

joined:Mar 15, 2013
posts: 997
votes: 95


But I am curious about one minor issue.

Let's say that the sender's username is (csdude), with the parentheses. And my From: is:

From: $username <example\@example.com>

The ( ) throws it off, so when I get the email it says it's from:

) <example@example.com>

So what do I need to do? Convert them to %28 and %29?
3:42 am on Dec 14, 2018 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11522
votes: 177


parentheses in the local part of email addresses must be quoted (i.e. preceded by a backslash)
6:26 pm on Dec 27, 2018 (gmt 0)

Senior Member

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

joined:Mar 30, 2006
posts:1569
votes: 116


Nice, thanks for sharing, it can be a real headache. I've been using (lucky me) sendmail with to and from for years ago.