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

Posted December 22, 2016 17.9k views
ApacheWordPressLAMP StackEmailUbuntu 16.04

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: “” (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 “” 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=<>, size=383, nrcpt=1 (queue active)
Dec 22 11:17:07 foobar postfix/smtp[12791]: EC576D82A: to=<>,[]: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

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.

Submit an Answer
2 answers

By the logs, Google got message but for some reason message was not delivered to the inbox.
You should set Droplet hostname to 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
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?.

by Pablo Carranza
A carefully tailored SPF record will reduce the likelihood of your domain name getting fraudulently spoofed and keep your messages from getting flagged as spam before they reach your recipients.

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 '' and also set myhostname in the /etc/postfix/ file to (already done that). right?!

Also I could add a new SPF record of my domain like so:
TXT @ "v=spf1 a ~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?

  • Hi,

    I should have been more specific with hostname change. You should change it in DO Cloud Control Panel. By changing Droplet hostname to fully qualified domain name (FQDN, e.x. you’ll create PTR record for it.
    So Login to Control Panel, open your Droplet detail page, and click on it’s name there. You’ll see box to change name, change it to domain name and click blue button with check mark.
    After you do this, in Networking -> PTR records, you can verify is it created successfully.

    About SPF. Above one is an example, you should add record like: TXT @ "v=spf1 ~all" so it matches your domain.

    About MX records - basically, for a SMTP (sending) only server, you don’t need MX records. MX records states where mail sent to domain should go, not who send it. So that should not make any problem.

    Yep, email is sent and it’s send to correct destination - Google. But it doesn’t end in users inbox. Could be many reasons, maybe your IP is blacklisted, maybe domain (but if you didn’t sent mails before, should not be a case). Make sure you don’t send mails that match spam pattern (like You won this big prize, please give us your details ).