Question

LAMP with Postfix says status=sent but no mails are delivered

Hi guys!

So I setup a fresh droplet using DigitalOcean’s “LAMP on Ubuntu 16.04” preconfigured thingy. I also followed some tuts, for example this one.

Everything works just fine, except the whole e-mail stuff. I want to host a standard Wordpress site on this droplet and of course also need to send mails (contact forms and stuff). But I can’t for the life of me get the whole postfix email thing to work.

My setup: Domain: “foobar.at” (A-record set to droplet IP, MX record I left as standard from my DNS provider - do I need to change the MX record maybe??) droplet hostname: “foobar” (not “foobar.at” or “foobar-at”) Distro: Ubuntu 16.04 LTS Standard LAMP Stack UFW Firewall with ports 25 and 587 open

When I try to send a mail via

echo "This is the body of the email" | mail -s "This is the subject line" your_email_address

or just using a simple php script I call via the browser, the following logs appear in my /var/log/mail.log:

Dec 22 11:17:06 foobar postfix/qmgr[12785]: EC576D82A: from=<www-data@foobar.at>, size=383, nrcpt=1 (queue active)
Dec 22 11:17:07 foobar postfix/smtp[12791]: EC576D82A: to=<myaddress@gmail.com>, relay=gmail-smtp-in.l.google.com[173.194.69.26]:25, delay=0.52, delays=0.01/0.01/0.34/0.17, dsn=2.0.0, status=sent (250 2.0.0 OK 1482405427 em6si31461231wjb.114 - gsmtp)
Dec 22 11:17:07 foobar postfix/qmgr[12785]: EC576D82A: removed

So if I understand this correctly it says status=sent (250 2.0.0 OK) which sounds good to me. But I do not receive any emails … not even in the spam folder of gmail!

What am I doing wrong? What am I missing here? Maybe something with my domain records is wrong?

Thanks a bunch in advance, best P


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

By the logs, Google got message but for some reason message was not delivered to the inbox. You should set Droplet hostname to foobar.at so it creates PTR record for your Droplet and make reverse lookup possible. This is important for anti-spam.

You also want to be sure that you set up https://www.digitalocean.com/community/tutorials/how-to-use-an-spf-record-to-prevent-spoofing-improve-e-mail-reliability#components-of-an-spf-record. Try sending email to other address or service to see is it blocking.

There are also many great resources over the Internet that can give you some hints: Prevent mail being marked as spam. postfix says mail sent ok, message does not arrive in ISPs inbox? no reject in log?.

Thanks for your answer!

I already read the serverfault issue you posted last but it didn’t really help me.

So what you are saying is that I should do hostnamectl set-hostname 'foobar.at' and also set myhostname in the /etc/postfix/main.cf file to foobar.at (already done that). right?!

Also I could add a new SPF record of my domain like so: TXT @ "v=spf1 a include:_spf.google.com ~all" is this SPF record correct?

Any other ideas? Do I have to change my MX records from the default of my domain/dns provider (NOT digitalocean) or can I leave them as is?

If I understand you correctly status=sent (250 2.0.0 OK) definitely means, that my postfix config is correct and the message is sent, but for some reason it does not show up in my inbox? is that correct?