Postfix: 554 Relay access denied

Let's say you have a user who can't receive e-mail. Each time they send a message to the server, this pops up in the mail logs:

postfix/smtpd[23897]: NOQUEUE: reject: RCPT from remotemailserver.com[10.0.0.2]: 554 <user@domain.com>: Relay access denied; from=<user@otherdomain.com> to=<user@domain.com> proto=ESMTP helo=<remotemailserver.com>

This is happening because Postfix is receiving e-mail for a domain for which it doesn't expect to handle mail. Add the domains to the mydestination parameter in /etc/postfix/main.cf:

mydestination = domain.com, domain2.com, domain3.com

If you have a lot of domains to add, create a mydomains hash file and change the mydestination parameter:

mydestination = hash:/etc/postfix/mydomains

Create /etc/postfix/mydomains:

localhost               OK
localmailserver.com     OK
domain.com              OK

Then run:

# postmap /etc/postfix/mydomains

This will create the hash file (mydomains.db) within /etc/postfix. If you've just added the directive to the main.cf, run postfix reload. However, if the directive was already there, but you just adjusted the mydomains and ran postmap, then there is nothing left to do.

Printed from: http://rackerhacker.com/2007/08/30/postfix-554-relay-access-denied/ .
© Major Hayden 2012.

8 Comments   »

  • alvin peezoot says:

    looking for this
    thanks it works.....

  • This is it! Thanks!

  • jeffrey Fan says:

    that is my problem.

    it works after fixing it!
    thanks a lot.

  • arjan ten hoopen says:

    I had that problem, fixed it in just a minute with your explanation. Thanks a lot!!!

  • tahiriman says:

    Thanks for your explanation

    I have a small concern, emails coming from my network are sent towards outside successfully
    on the other hand those received from an external client (outside my network) have this problem (relay denied)

    Excuse me, my English isn't will

  • Karthikeyan Krish says:

    Thanks. It gave an idea of what prob i do have.

  • Lucian says:

    HI Hayden

    I have similar problem. For the beginning I added a "yahoo.com" to 'mydestination =" as you suggets. Still I cannot get email into my squirrel-mail account.

    I can send out emails using squirrel-mail but I cannot receive.

    the mail log error looks like

    Mar 1 19:26:31 ns1 dovecot: Dovecot v1.2.15 starting up (core dumps disabled)
    Mar 1 19:29:30 ns1 postfix/smtpd[31768]: connect from nm19-vm0.bullet.mail.bf1.yahoo.com[98.139.213.162]
    Mar 1 19:29:31 ns1 postfix/smtpd[31768]: NOQUEUE: reject: RCPT from nm19-vm0.bullet.mail.bf1.yahoo.com[98.139.213.162]: 554 5.7.1 : Relay access denied; from= to= proto=SMTP helo=
    Mar 1 19:29:31 ns1 postfix/smtpd[31768]: disconnect from nm19-vm0.bullet.mail.bf1.yahoo.com[98.139.213.162]

    the postconf -n is

    alias_database = hash:/etc/aliases
    alias_maps = hash:/etc/aliases
    append_dot_mydomain = no
    biff = no
    config_directory = /etc/postfix
    home_mailbox = .mail/
    inet_interfaces = all
    mailbox_size_limit = 0
    mydestination = datastore.ro., ns1, localhost.localdomain, localhost, yahoo.com.
    myhostname = ns1
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    myorigin = /etc/mailname
    readme_directory = no
    recipient_delimiter = +
    relayhost =
    smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
    smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
    smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_local_domain = yourdomain.com
    smtpd_sasl_security_options = noanonymous
    smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
    smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
    smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
    smtpd_use_tls = yes

    Can you help me please?
    Have a great day

  • Arfat says:

    Hello Hayden,

    I am facing the same issue not able to send the mail from Remote SASL Auth. My postconf -n is

    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 = direction.biz
    myorigin = $mydomain
    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
    relayhost = [mail.otto4u.com]:587
    sample_directory = /usr/share/doc/postfix-2.6.6/samples
    sendmail_path = /usr/sbin/sendmail.postfix
    setgid_group = postdrop
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options =
    smtp_sasl_type = cyrus
    smtpd_sasl_path = smtpd
    unknown_local_recipient_reject_code = 550

    And facing the below error in Postfix Maillog.

    May 17 09:32:34 oplq-test postfix/smtp[10151]: 77EA0150641: to=, relay=mail.otto4u.com[72.35.73.86]:587, delay=2.1, delays=0.05/0.02/1.5/0.52, dsn=5.0.0, status=bounced (host mail.otto4u.com[72.35.73.86] said: 554 qmail-dk: Cannot sign message due to invalid message syntax. (#5.3.0) (in reply to end of DATA command))
    May 17 09:32:34 oplq-test postfix/cleanup[10149]: 98056150643: message-id=

    Pls help me i had just stuck in this issue.

RSS feed for comments on this post

Leave a Reply

 

  • Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you find the information useful. If you spot something that's incorrect or confusing, please write a comment and let me know. Drop me a line if there's something you want to know more about and I'll do my best to write a post on the topic.
    -- Major Hayden