Fixing 'Relay access denied' in Postfix

16,526

So and where did you specify for which domains Postfix should be responsible? Nowhere. This is why you get this error. Add your domain to the line of mydestination. And then you need at least a local user named developer or put an alias into /etc/aliases.

But you have to read this documentation as an absolute minimum before you start with Postfix: http://www.postfix.org/BASIC_CONFIGURATION_README.html

Share:
16,526

Related videos on Youtube

MacMac
Author by

MacMac

Updated on September 18, 2022

Comments

  • MacMac
    MacMac over 1 year

    Before you claim about duplicates and so on, I've checked these topics:

    The above topics doesn't solve my problems, perhaps this is something to do with my configuration file which totally differs to one of the topics above, so I'm posting a new fresh topic.

    I'm trying to set up Postfix to work with sending emails and mail aliases. If I send an email with my hotmail account to [email protected] I get a reply from hotmail saying:

    This is an automatically generated Delivery Status Notification.
    
    Delivery to the following recipients failed.
    
          [email protected]
    
    
    
    Reporting-MTA: dns;blu0-omc4-s15.blu0.hotmail.com
    Received-From-MTA: dns;BLU0-SMTP148
    Arrival-Date: Thu, 10 Nov 2011 08:31:02 -0800
    
    Final-Recipient: rfc822;[email protected]
    Action: failed
    Status: 5.7.1
    Diagnostic-Code: smtp;554 5.7.1 <[email protected]>: Relay access denied
    
    From: My name <[email protected]>
    Subject: Testing
    Date: 10 November 2011 16:30:58 GMT
    To: [email protected]
    
    This is a typical test
    

    I already have the mail aliases set up, pointing to the correct emails and such.

    This is the /etc/postfix/main.cf I have.

    # See /usr/share/postfix/main.cf.dist for a commented, more complete version
    
    
    # Debian specific:  Specifying a file name will cause the first
    # line of that file to be used as the name.  The Debian default
    # is /etc/mailname.
    #myorigin = /etc/mailname
    
    smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
    biff = no
    
    # appending .domain is the MUA's job.
    append_dot_mydomain = no
    
    # Uncomment the next line to generate "delayed mail" warnings
    #delay_warning_time = 4h
    
    readme_directory = no
    
    # TLS parameters
    smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
    smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
    smtpd_use_tls=yes
    smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
    smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
    
    # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
    # information on enabling SSL in the smtp client.
    
    myhostname = localhost
    alias_maps = hash:/etc/aliases
    alias_database = hash:/etc/aliases
    mydestination = $mydomain, $myhostname, localhost, localhost.localdomain, , localhost
    #relayhost = 
    relayhost = $mydomain
    
    #mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    mynetworks = 192.168.1.0/24 127.0.0.0/8
    
    mailbox_command = procmail -a "$EXTENSION"
    mailbox_size_limit = 0
    recipient_delimiter = +
    inet_interfaces = all
    

    Here's an log when I sent an email:

    Nov 10 18:29:42 website postfix/smtpd[3320]: connect from blu0-omc4-s8.blu0.hotmail.com[65.55.111.147]
    Nov 10 18:29:42 website postfix/smtpd[3320]: BA882D90044: client=blu0-omc4-s8.blu0.hotmail.com[65.55.111.147]
    Nov 10 18:29:42 website postfix/cleanup[3324]: BA882D90044: message-id=<[email protected]>
    Nov 10 18:29:42 website postfix/qmgr[3143]: BA882D90044: from=<[email protected]>, size=1107, nrcpt=1 (queue active)
    Nov 10 18:29:42 website postfix/cleanup[3324]: E91B9D90047: message-id=<[email protected]>
    Nov 10 18:29:42 website postfix/local[3325]: BA882D90044: to=<[email protected]>, relay=local, delay=0.29, delays=0.28/0.01/0/0, dsn=2.0.0, status=sent (forwarded as E91B9D90047)
    Nov 10 18:29:42 website postfix/qmgr[3143]: E91B9D90047: from=<[email protected]>, size=1231, nrcpt=1 (queue active)
    Nov 10 18:29:42 website postfix/qmgr[3143]: BA882D90044: removed
    Nov 10 18:29:42 website postfix/smtp[3326]: warning: relayhost configuration problem
    Nov 10 18:29:42 website postfix/smtp[3326]: E91B9D90047: to=<[email protected]>, orig_to=<[email protected]>, relay=none, delay=0.02, delays=0/0.01/0.02/0, dsn=4.3.5, status=deferred (mail for mail.domain.com loops back to myself)
    Nov 10 18:29:43 website postfix/smtpd[3320]: disconnect from blu0-omc4-s8.blu0.hotmail.com[65.55.111.147]
    

    After removing relayhosts line:

    Nov 10 18:37:23 website postfix/smtpd[3596]: connect from blu0-omc4-s9.blu0.hotmail.com[65.55.111.148]
    Nov 10 18:37:23 website postfix/smtpd[3596]: 7DD9DD90044: client=blu0-omc4-s9.blu0.hotmail.com[65.55.111.148]
    Nov 10 18:37:23 website postfix/cleanup[3601]: 7DD9DD90044: message-id=<[email protected]>
    Nov 10 18:37:23 website postfix/qmgr[3595]: 7DD9DD90044: from=<[email protected]>, size=2223, nrcpt=1 (queue active)
    Nov 10 18:37:23 website postfix/cleanup[3601]: B1D59D90048: message-id=<[email protected]>
    Nov 10 18:37:23 website postfix/local[3602]: 7DD9DD90044: to=<[email protected]>, relay=local, delay=0.32, delays=0.32/0/0/0, dsn=2.0.0, status=sent (forwarded as B1D59D90048)
    Nov 10 18:37:23 website postfix/qmgr[3595]: B1D59D90048: from=<[email protected]>, size=2347, nrcpt=1 (queue active)
    Nov 10 18:37:23 website postfix/qmgr[3595]: 7DD9DD90044: removed
    Nov 10 18:37:23 website postfix/smtpd[3596]: disconnect from blu0-omc4-s9.blu0.hotmail.com[65.55.111.148]
    Nov 10 18:37:24 website postfix/smtp[3603]: B1D59D90048: to=<[email protected]>, orig_to=<[email protected]>, relay=mx4.hotmail.com[65.54.188.126]:25, delay=1.1, delays=0/0/0.51/0.55, dsn=2.0.0, status=sent (250 mail from IP 94.75.251.47 soft failed sender ID check. Please ensure this IP is authorized to send mail on behalf of [hotmail.co.uk])
    Nov 10 18:37:24 website postfix/qmgr[3595]: B1D59D90048: removed
    
  • MacMac
    MacMac over 12 years
    Thanks for the reply. I added mydomain = domain.com and changed relayhost to relayhost = mail.$mydomain. I get no more error mail from hotmail, but I don't see it in the aliased email inbox. Something wrong?
  • mailq
    mailq over 12 years
    @YouBook Probably. But without log messages I can't help (new question!). I'm not that good at divination.
  • MacMac
    MacMac over 12 years
    Ah yes, updated my post.
  • mailq
    mailq over 12 years
    @YouBook Remove the line with relayhost (completely!).
  • MacMac
    MacMac over 12 years
    Updated my post again.
  • mailq
    mailq over 12 years
    Hotmail doesn't allow to receive mails that were sent by Hotmail. So you should not alias a local user back to Hotmail. This is not the fault of Postfix but prevents spamming. Don't argue with me, discuss this with Microsoft.
  • MacMac
    MacMac over 12 years
    LOL. I guess this solves the problem, just tested using Google mail, works well. Thanks!
  • StrikeForceZero
    StrikeForceZero about 11 years
    I've spent last 6 hours trying to fix this. exact same config layout. Comments were the answer Thank You!