How to debug Sendmail

Hi. I'm new to all this. I have set up a linode with Ubuntu 16.04 and installed a LAMP set up. My website is running just fine.

The only problem is sending mail from PHP. I have installed sendmail.

I typed hostname to get my server hostname…

I then updated my /etc/hosts file…

127.0.0.1       localhost localhost.localdomain MY_HOSTNAME
127.0.1.1       ubuntu.members.linode.com       ubuntu
127.0.1.1       MY_HOSTNAME

I run sendmailconfig and restart apache. Everything I read says this should work.

My PHP script seems to run without errors. (It worked on my previous server). I have checked my apache error log, php error log and my web app error log. No related errors.

Can anyone advice me on how to debug the problem?

Thanks,

Jonathan

7 Replies

I made a little progress. I ran…

echo "Subject: sendmail test" | sendmail -v valid.email@test.com

And got a response including…

050 550-5.7.1 [2a01:7e00::f03c:91ff:fef4:d22f] Our system has detected that this
050 550-5.7.1 message does not meet IPv6 sending guidelines regarding PTR records
050 550-5.7.1 and authentication. Please review
050 550-5.7.1  https://support.google.com/mail/?p=IPv6AuthError for more information
050 550 5.7.1 . x63si14327053wmf.220 - gsmtp

I followed the link https://support.google.com/mail/?p=IPv6AuthError

There is a lot of info but one point is …

> Keep valid reverse DNS records for the IP address(es) from which you send mail, pointing to your domain.
However, I haven't set up a domain name yet. I'm just using my local hosts file to point at the IP address of the server. So, I can't set up reverse dns. Could that be the problem?

Okay, first off, uninstall sendmail and install something more sane like Postfix. Second, unless you absolutely need IPv6, disable it on machine level. Third, assign proper reverse DNS to the Linode. Gmail will absolutely refuse to accept mail unless one is assigned and even then will most likely demand you set up SPF.

This is a hacky minimum-effort setup. Your deliverability will be low. If you want a proper setup, you'd want a separate mailserver like iredmail, with DKIM and SPF configured, and joined to Microsoft JMRP, you'll need to verify your IP isn't on RBL anywhere and so on.

Hi, thanks for your response.

I haven't had a chance to test it yet but last night I realised that when you want to send mail you need a valid, resolving FQDN. As I'm just playing (and learning) with this server, I hadn't set one up yet. (I set the hostname but its not a FQDN). I'll do that and see what happens.

From your message, it sounds like Postfix has superseded sendmail? That makes sense because all the guides are for postfix! I will have a play with Postfix.

Regarding deliverability, the goal is simply to send contact messages through a web form, so they will just be going to one address and I can set up a rule to keep them out of spam. Hopefully that will be enough. And I'll look into SPF if needed.

Thanks for your help and advice.

Also, can I ask why you recommend disabling IPv6? Thanks.

You not only need a valid FQDN; in most cases, you need your mailserver to pronounce this FQDN in the HELO/EHLO command when connecting to another server (smtpheloname configuration item in postfix), and you need your IP rDNS to resolve to that FQDN. Many servers will take the IP you connect from, resolve its rDNS, verify that it resolves, then resolve it back and compare that to your MTA's hello greeting. This is a common anti-spam technique that makes it way costlier for spammers.

Sendmail is a very powerful mail server. However, it is very old, extremely arcane in terms of configuration, and has a nasty legacy of security issues because most of it was written before developers were generally conscious of security. Postfix is a cleaner, safer and neater MTA. If I operated very large clusters of MTAs with enormous volumes of mail and needed every bit of performance and configurability and iron clad reliability, I would prefer qmail; in all other cases Postfix is the way to go for me (I run dozens of Postfix-based mailservers).

If your destination address is gmail, then yes, you would need at least rDNS and SPF. However, there is a better alternative: install a zero-MTA such as nullmailer and configure it to authenticate to gmail SMTP and send emails on behalf of your account. This works great on low volume of email and spares you the intricate configuration of a full mail server.

That did the trick! - Valid FQDN, sendmail configured to use it (by running sendmailconfig), IP rDNS on both IPv4 and IPv6 and an SPF TXT record. Emails sending fine from the command line and from PHP.

Think that is enough for my needs. Will have a play with Postfix when I have a spare evening.

Still not sure why you recommended disabling IPv6 at a machine level but guess that's a conversation for another day and a new thread.

Thanks for your help!

I guess you made changes in /etc/hosts to have a valid FQDN?

i will change to Postfix to later, but for now i need to install and configure sendmail, can you pls point out what you did to fix the problem,. I been running sendmailconfig with no luck, missing parameters i guess.

Pls help.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct