By stroschit
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
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!
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?
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?.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.