0

I recently changed my mail provider and now I'm unable to receive emails from crontab. In my maillog:

Sep 12 02:57:25 myhostname postfix/qmgr[14013]: 4BEE35D8005A:
from=<root@myhostname.localdomain>, size=886, nrcpt=1 (queue active)
Sep 12 02:57:28 myhostname postfix/smtp[50109]: 4BEE35D8005A:
to=<myname@mydomain.com>,
relay=mx.newmailserver.com[XXX.XXX.XX.XX]:25, delay=144207,
delays=144204/0.01/1.3/1.8, dsn=4.7.1, status=deferred (host
mx.newmailserver.com[XXX.XXX.XX.XX] said: 450 4.7.1 Client host rejected:
cannot find your hostname, [YYY.YYY.YYY.109] (in reply to RCPT TO
command))

In my resolv.conf:

nameserver YYY.YYY.YYY.22 
search com

This server points to a subdomain of mine. The result of dig myhostname.localdomain:

;; QUESTION SECTION:
;myhostname.localdomain.    IN      A

;; AUTHORITY SECTION:
        54766   IN      SOA     a.root-servers.net. nstld.verisign-grs.com. 2016091600 1800 900 604800 86400                          

I've read that this 'Client host rejected' error is related to reverse PTR, but I have no idea where and what I have to write in this record.

PS: the names starting with my and the IP numbers were changed, but the rest is exaclty as it is writen (ex: nameserver, localdomain...)

  • Are myhostname.localdomain and mydomain.com connected directly, or do you have to go through a WAN link to connect them? – Xalorous Sep 16 '16 at 17:33
  • @Xalorous They're not directly connected. – carla Sep 16 '16 at 17:36
  • Ahh, the answers below are the right way since you have to go through a relay. – Xalorous Sep 16 '16 at 17:45
2

Usually mail servers check for reverse DNS field (a.k.a PTR DNS entry). Usually, this is done to verify that an email server, announcing "working" from a domain is really from it. Having also MX record in the DNS would help.

You should ensure that you reverse DNS value match your email domain that your server is announcing about.

2

There are a few things that you always want setup if you are going to run your own mail server. If you leave any of these off then you will likely find your emails is being blocked by more than one provider at some point in time.

MX Record

A mail exchange (MX) Record is an entry in your DNS zone file that identifies the server that is responsible for receiving email going to your domain.

If you don't have an MX Record do not expect to receive email.

You can lookup your MX Record with MX Lookup at www.mxtoolbox.com.

PTR Record

One of the most common reasons for a provider refusing to accept email you sent is if you do not have a Pointer (PTR) Record.

When your mail server send an email it tells the receiving server what its hostname and IP address are.

The receiving server will take the IP address and say great what is the hostname for the IP address. If the DNS server comes back and says that the hostname for the IP address the email came from is different than the hostname the server that the email came from claimed it is, then the receiving server may reject the email.

You can check your PTR Record with Reverse Lookup at www.mxtoolbox.com.

SPF Record

A Sender Policy Framework (SPF) Record tells the world what servers are allowed to send email address for your domain name.

More companies are enabling SPF checking on their mail filters. If you send an email to one of those companies who have SPF checking turned on and the server that sent your email is not included in your SPF Record (or if you don't have an SPF Record) your email will be blocked.

You can lookup your SPF Record with SPF Record Lookup at www.mxtoolbox.com.

What Do I Need to Do to Create These DNS Records?

For an MX or SPF Record, you might be able to create the records yourself provided your provider gives you the ability to modify the DNS records in your zone file.

If you need to create a PTR Record, contact your provider and have them create a PTR Record. You will need to specify the hostname and the Public IP address you are using for your mail server.

  • mydomain.com has all records set. I just need this second server, that points to sub.domain.com to be able to send, not receive emails. In fact, Gmail receives its emails, this new email provider doesn't. Should I edit the DNS of my domain and add a PTR of YYY.YYY.YYY.109 pointing to sub.domain.com? – carla Sep 16 '16 at 18:16
  • Generally, your ISP has to be the one to create a PTR for the public IP address that is going to be sending email. Yes, if the server is going to send email the public IP address needs to have a matching PTR record. – user5870571 Sep 16 '16 at 19:36
0

This DNS thing wasn't clear in my head, so for those who come here with the same difficulties:

  • my server was hosted at HostCompany (e.g. OVH, LeaseWeb)
  • my domain was registered at DNSCompany (e.g. Amazon Route 53, Verio)
  • my email was hosted at MailCompany (e.g. GoDaddy, GMail)

Sending emails using cronjob from my server to my email was getting blocked.

  • the default sender of the cronjob was "root@nodeX.localdomain".
  • using MXToolBox with my IP and the option "Reverse Lookup" showed 'mail.mydomain.com'
  • using MXToolBox again but with 'mail.mydomain.com' and the Option "DNS Lookup" showed the IP of MailCompany.

So the solution was:

  • in my HostCompany*, I changed the PTR record to 'mydomain.com' (since I have an A record at DNSCompany that points my IP to 'mydomain.com')
  • set the option MAILFROM="root@mydomain.com" in my cronjob

*this info was the most important for me, because I thought I had to change something in my DNSCompany

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.