Postfix send email but not receive it. NOQUEUE: reject: RCPT from ; Relay access denied

5,745

Your mydestination doesn't have mail.example.com, just the plain example.com.

mydestination = $myhostname localhost.$mydomain localhost
myhostname = example.com

You could add it e.g. like this:

mydestination = $myhostname mail.$myhostname localhost.$mydomain localhost

However, you probably want to receive mail for [email protected], not mail.example.com? For this you'd need to set MX for it, instead:

example.com.         IN      MX      10 mail.example.com.
mail.example.com.    IN      A       198.51.100.100
Share:
5,745
Marcos
Author by

Marcos

Analítico e lógico. Organizado e orientado ao detalhe e aos resultados. Proposição e comunicação de forma simples com soluções agregadoras. 29+ years experience in software and IT hardware industry. 25+ years experience Solution architecture, Setting up IT systems, Modeling DBMS data (according to Chris Gane), programming, modeling report, DBs SQL. 5+ years experience with Clouds, EC2, Serverless, Web servers, Applications servers, programming CPython, modeling NoSQL data, DBs NoSQL, Queues, Django, Flask e FastAPI frameworks. My main stack is Python and its technologies Python projects: a) Web, Database, Legacy database b) Sending e-mails c) Async tasks and queues d) Compiling Python at the speed of C (or Fortran) with Cython and Numba e) IoT with Raspberry Pi, Modules and Sensor, Arduino, NodeMCU ESP8266 e ESP32 f) MicroPython for embedded systems (sistemas embarcados)

Updated on September 18, 2022

Comments

  • Marcos
    Marcos almost 2 years

    Postfix was configured and it can send emails using gmail domain relay. However Postfix can't receive emails from external domains.

    My internal email is: [email protected]

    Versions: Ubuntu 17.10 (Artful Aardvark) ; Postfix 3.2.3

    Below my setups;

    • The ports 25 and 587 are open in GCP where postfix was configured

    • There is an user commercial name created in Linux where postfix was configured

    • MX and A DNS were setup and below you can see report yielded from dig linux command:

    Below my extra setups;

    something.com.         59      IN      MX      10 mail.something.com.
    mail.something.com.    59      IN      A       <SOMETHING IP ADDRESS>
    

    $ sudo postconf -n

    alias_database = hash:/etc/aliases
    alias_maps = hash:/etc/aliases
    append_dot_mydomain = no
    biff = no
    compatibility_level = 2
    home_mailbox = Maildir/
    inet_interfaces = all
    inet_protocols = all
    mailbox_size_limit = 0
    mydestination = $myhostname mail.$myhostname localhost.$mydomain localhost
    myhostname = something.com
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    myorigin = /etc/mailname
    readme_directory = no
    recipient_delimiter = +
    relayhost = [smtp.gmail.com]:587
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options =
    smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
    smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
    smtp_use_tls = yes
    smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
    smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
    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
    virtual_alias_maps = hash:/etc/postfix/virtual
    

    $ sudo postconf -M

    smtp       inet  n       -       y       -       -       smtpd
    submission inet  n       -       y       -       -       smtpd
    pickup     unix  n       -       y       60      1       pickup
    cleanup    unix  n       -       y       -       0       cleanup
    qmgr       unix  n       -       n       300     1       qmgr
    tlsmgr     unix  -       -       y       1000?   1       tlsmgr
    rewrite    unix  -       -       y       -       -       trivial-rewrite
    bounce     unix  -       -       y       -       0       bounce
    defer      unix  -       -       y       -       0       bounce
    trace      unix  -       -       y       -       0       bounce
    verify     unix  -       -       y       -       1       verify
    flush      unix  n       -       y       1000?   0       flush
    proxymap   unix  -       -       n       -       -       proxymap
    proxywrite unix  -       -       n       -       1       proxymap
    smtp       unix  -       -       y       -       -       smtp
    relay      unix  -       -       y       -       -       smtp
    showq      unix  n       -       y       -       -       showq
    error      unix  -       -       y       -       -       error
    retry      unix  -       -       y       -       -       error
    discard    unix  -       -       y       -       -       discard
    local      unix  -       n       n       -       -       local
    virtual    unix  -       n       n       -       -       virtual
    lmtp       unix  -       -       y       -       -       lmtp
    anvil      unix  -       -       y       -       1       anvil
    scache     unix  -       -       y       -       1       scache
    maildrop   unix  -       n       n       -       -       pipe flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
    uucp       unix  -       n       n       -       -       pipe flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
    ifmail     unix  -       n       n       -       -       pipe flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
    bsmtp      unix  -       n       n       -       -       pipe flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
    scalemail-backend unix - n       n       -       2       pipe flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
    mailman    unix  -       n       n       -       -       pipe flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user}
    

    I spent a lot of hours trying to solve it but until now I couldn't because probably it's not my main skill. I'm getting better...

    Could you please check it and guide me to turn on the postfix to receive email? Thanks

  • Marcos
    Marcos over 6 years
    I did what you told me. Postfix sends email, but to receive the message: "NOQUEUE: reject" "Relay access denied" still continue showing on the log file. I mean, postfix doesn't receive email from external domains.
  • Marcos
    Marcos over 6 years
    checking deeply the configuration I solve it. Thanks to Esa Jokinen for your insights. The setups are updated to help some friend on it.
  • Esa Jokinen
    Esa Jokinen over 6 years
    Due to the Q/A nature it'd be better if you keep the errors on your question and answer with the necessary modifications.
  • kittygirl
    kittygirl over 5 years
    @EsaJokinen, DNS setting should use @ instead of domain.com.For example,@ IN MX 10 mail.example.com.
  • Esa Jokinen
    Esa Jokinen over 5 years
    @kittygirl: The @ is substituted with zone apex in the BIND zones. Therefore, @ equals example.com. and both can be used, but @ alone in examples doesn't mean anything specific. See zytrax.com/books/dns/apa/origin.html
  • kittygirl
    kittygirl over 5 years
    @EsaJokinen,with your DNS setting, only change myhostname = example.com to myhostname = mail.example.com.is that ok?
  • Esa Jokinen
    Esa Jokinen over 5 years
    That would require additional example.com in mydestination.