554 5.7.1 <mail_addr>: Relay access denied centos postfix

Solution 1:

Based on the Postfix documentation, setting mynetworks = all doesn't appear to be valid, and if you specifically set mynetworks to something, then mynetworks_style is ignored.

Reset mynetworks back to its default value if you want to use mynetworks_style=host, or explicitly set mynetworks to reflect where mail is being sent from (usually localhost and your local subnet). For example:

mynetworks = 127.0.0.0/8 192.168.1.0/24
mynetworks_style = subnet

Solution 2:

You are trying you relay email to gmail but your configuration does not accept relaying mails to gmail so it returns 554 reject code. in postconf

relay_domains_reject_code (default: 554) The numerical Postfix SMTP server response code when a client request is rejected by the reject_unauth_destination recipient restriction.

to fix relaying problem correct value of mydestination parameter according to postconf

relay_domains (default: $mydestination) What destination domains (and subdomains thereof) this system will relay mail to. For details about how the relay_domains value is used, see the description of the permit_auth_destination and reject_unauth_destination SMTP recipient restrictions.

Domains that match $relay_domains are delivered with the $relay_transport mail delivery transport. The SMTP server validates recipient addresses with $relay_recipient_maps and rejects non-existent recipients. See also the relay domains address class in the ADDRESS_CLASS_README file.

Note: Postfix will not automatically forward mail for domains that list this system as their primary or backup MX host. See the permit_mx_backup restriction in the postconf(5) manual page.

Specify a list of host or domain names, "/file/name" patterns or "type:table" lookup tables, separated by commas and/or whitespace. Continue long lines by starting the next line with whitespace. A "/file/name" pattern is replaced by its contents; a "type:table" lookup table is matched when a (parent) domain appears as lookup key. Specify "!pattern" to exclude a domain from the list. The form "!/file/name" is supported only in Postfix version 2.4 and later.

Pattern matching of domain names is controlled by the presence or absence of "relay_domains" in the parent_domain_matches_subdomains parameter value.