Postfix: Sender address rejected: Domain not found (in reply to RCPT TO command))

If you are trying to send emails from a local application on a CentOS machine that is not a primary mail server, then you might hit the

Sender address rejected: Domain not found (in reply to RCPT TO command))
error. In this case you need to rewrite the outgoing address that is being rejected to something that make sense with the proper domain for the users.

Here are the quick steps to accomplish this:

nano /etc/postfix/main.cf

Modify the "mydomain" variable to your email domain

mydomain = example.com

Make sure to uncomment the proper network interface. I'm usually lazy and just do all.

inet_interfaces = all

Now at the bottom of this file you need to specify the canonical map file for rewriting the address.

sender_canonical_maps = hash:/etc/postfix/canonical

Save and exit main.cf. Now we need to edit /etc/postfix/canonical

nano /etc/postfix/canonical

You need to specify the mapping of the original address to the one you want. Since in this case I just want to rewrite everything I usually add the following two lines and it seems to catch everything.

root@host.example.com no-reply@example.com
 @example.com       no-reply@example.com
 

Save and exit the file. Now we need to create the postfix db.

postmap /etc/postfix/canonical

Now just restart postfix and test.

/etc/init.d/postfix restart
 

Restart postfix and test.

Comments

Post new comment

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
To prevent automated spam submissions leave this field empty.