I'm trying to setup a postfix server for testing our app which uses oracle mail library javax.mail to send mail. The app works fine as I'm able to use google, our own mail server, etc to send mail.

The problem I'm getting when sending an ehlo test is 5.7.1 relay access denied. I see there are hundreds of these questions but none have helped me understand how this actually works.

If I list yahoo.com as a 'relay_domain' in main.cf, I can send mail to a yahoo recepient. I am not really grasping what this means, do I list all domains I want to send mail to here (surely not). Sorry for the noob style question but most of the guides for this seem to be geared for people with a better understanding of how email works.

postfix is running on centOS.

Here's my config differences.

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
html_directory = no
inet_interfaces = localhost
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,    mail.$mydomain, www.$mydomain, ftp.$mydomain
mydomain = *****.com
myhostname = mail.*****.com
mynetworks =,
myorigin = $myhostname
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
relay_domains = $mydestination
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550

mynetworks =

That can't possibly be right since there is no /200 netmask. This causes your postfix to refuse mail from trusted hosts in the network.

Using relay_domains the way you describe it is not how it's supposed to be. This statement is used for maildomains for which you're supposed to handle (backup) mail, not for domains to which you're sending mail.

  • I set mynetworks, obviously I need to reread it's description. Keep in mind I'm not worried about receiving mail at this point. With that said, from what I understand, relay_domains should remain blank? Thanks. – Half_Duplex Mar 1 '14 at 19:32
  • If you're only using postfix to send out mail, relay_domains should be empty. You need to fix the netmask in my_networks to your actual local network to have postfix accept mail from those IP addresses. – Teun Vink Mar 1 '14 at 19:36
  • I was unable to figure out how to accurately enter my subnet mask, but that was the problem. I commented mynetworks and uncommented mynetwork_styles = subnet to make it easier for me and now have outbound mail. Thanks. – Half_Duplex Mar 1 '14 at 20:16
  • A good guess for your mask would be /24, judging by the network address (255 addresses on that net) – Cleber Goncalves Mar 2 '14 at 9:57

To clarify more about what domains to list where; Your MTA serves three important purposes.

  • You will have to receive mails for the domains you host. (In postfix, you list such domains under mydestination, virtual_alias_domains or virtual_mailbox_domains ) This can be termed as inbound mode of an MTA.

  • You will have to serve as backup MX server for some domains (not always) and you list such domains under relay_domains and your mail server will accept mails for these domains and forward them. So this can be termed as forwarding mode of an MTA.

  • Your internal users should be able to send out mails to anyone else in the world. Users generally authenticate and send out mails and this can be termed as outbound mode of an MTA.

Hope this helps. These things are explained clearly in Postfix Address Classes and Postfix SASL Readme

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.