Networking – Can’t send email to the internet from Postfix mail server. (Relay access denied)


I have a mail server running Postfix in my LAN with which I can send and receive emails in my LAN and send from the WAN to the LAN. I can't send from the LAN to the WAN though.

I am trying to use my ISP's relay host ( to solve this problem as it seems the simplest way (the relay doesn't require authentication).

With telnet I can connect directly to the relay host and send an email without authentication:

> telnet 25
Connected to
mail from:
250 Ok
rcpt to:
250 Ok
354 End data with <CR><LF>.<CR><LF>
This is a test
250 Ok: queued as 9BFD413BAE5

Trying to use the same relay on my postfix server gives me the Relay access denied error though (not sure which relay it means):

>telnet 25
mail from:
250 2.1.0 Ok
rcpt to:
554 5.7.1 <>: Relay access denied

My postfix configuration (

# TLS parameters
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

myhostname =
mydomain =
myorigin = $mydomain
smtpd_sender_restrictions = permit_mynetworks
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination =, ubuntu, localhost
relayhost =
mynetworks = [::ffff:]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

Any ideas what can be wrong?

Best Answer

Yes. Your server is denying relay to you. Because:

smtpd_sender_restrictions = permit_mynetworks
mynetworks = [::ffff:]/104 [::1]/128

So you have to add you IP range (the IP of your telnet client, for instance) to my_networks

mynetworks = [::ffff:]/104 [::1]/128

In case you telnet client's IP is

If your server is hosted on an ISP and you are using unknown dynamic IP range you will have to use SMTP authentication in your server. Or just leave your server as an open relay (which of course I wouldn't recommend).