I have problem in send mail from postfix in centos

I have following setup mail server postfix for sending mail but I am getting error.

As in the link I tried following commands

telnet localhost smtp

Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 mydomain.com ESMTP Postfix
ehlo localhost
250-SIZE 10240000
250 DSN
mail from:<domain.com>
250 2.1.0 Ok
rcpt to:<test@gmail.com>
554 5.7.1 <test@gmail.com>: Relay access denied


In terminal this works

echo TEST | mail -v -s "Test mail" testing@gmail.com

my postconf -n shows belog information

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
home_mailbox = Maildir/
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
mydomain = dummy.com
myhostname = dummy.com
mynetworks = all
mynetworks_style = host
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
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

What configuration I have to perform to send mails from my server.


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 =
mynetworks_style = subnet

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.

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.