Been having a bit of trouble getting my Ubuntu server to relay my mail to external addresses. Here's whats currently happening:

When I telnet locally to port 25 I can send email to any host just fine. However, when I try to connect from my Mac here to the server, I get a Relay Access Denied error after I enter the rcpt to: section of the message body.

So, my question is - why is this happening? How can I fix it? I'd ideally like to make it so any mail client anywhere can connect to a mailbox on my server (clients, etc.)

Here's my /etc/postfix/main.cf file:

# 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_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 = sites.domain.co.uk
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = sites.domain.co.uk, localhost.domain.co.uk, , localhost
relayhost = 
mynetworks = [::ffff:]/104 [::1]/128 <my_ip_address>
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

smtpd_client_restrictions = reject_rbl_client sbl.spamhaus.org, reject_rbl_client blackholes.easynet.nl, permit

Output of my Telnet session on the server:

root@sites:~# netcat localhost 25
220 <my_hostname> ESMTP Postfix (Ubuntu)
ehlo <some_host>
250-SIZE 10240000
250 DSN
mail from: <my_email>
250 2.1.0 Ok
rcpt to:<email>@googlemail.com
250 2.1.5 Ok
354 End data with <CR><LF>.<CR><LF>
250 2.0.0 Ok: queued as D5710120773
221 2.0.0 Bye

And the result when I try to telnet from my Mac:

iMac:~ user$ telnet <my_hostname> 25
Connected to <my_hostname>.
Escape character is '^]'.
220 <my_hostname> ESMTP Postfix (Ubuntu)
ehlo <some_host>
250-SIZE 10240000
250 DSN
mail from: <my_email>
250 2.1.0 Ok
rcpt to: <email>@googlemail.com
554 5.7.1 <<email>@googlemail.com>: Relay access denied

I've searched the site and tried various suggestions but none seem to be working for me! Any help would be greatly appreciated.


The mynetworks directive in main.cf specifies which networks the postfix server will relay for. Your current setting only allows the local host (the postfix server) to relay mail through itself.

mynetworks = [::ffff:]/104 [::1]/128 <my_ip_address>

Your Mac is on a separate network. Change mynetworks to allow the networks you want to allow. It might look like this for you:

mynetworks =,
  • Hi Joshua - thanks for your response but I want any server to be able to connect and send mail, as long as they have a valid user account of course. – tomhallam Oct 12 '13 at 22:39
  • You can set whatever networks to be allowed that you like, but I'd recommend against making it broader than it needs to be. If it's publicly accessible bad guys will use open relays for bad deeds. Regarding users: this is separate from users. This is based on IPs. If postfix won't accept mail from the requesting IP, it doesn't matter what user or source or destination email account is intended. – Joshua Miller Oct 12 '13 at 23:36

For delivery to this same server, you don't need relaying. Relaying is when connecting clients use your server to send mail to other servers.

Look at virtual_mailbox_domains, virtual_mailbox_base, virtual_alias_maps and virtual_mailbox_maps. You can configure what domains it will accept mail for, and what users you have.

  • Thank you for your reply - surely this doesn't answer why it works when I am on localhost vs. when I am connecting from an external computer? – tomhallam Oct 12 '13 at 13:40
  • 1
    When it comes to relaying, it does. is in mynetworks, so it can relay. – Halfgaar Oct 12 '13 at 13:41
  • So if I set up those configuration entities, it should recognise I'm connection from whatever machine? Surely I need to relay still even if I'm not on localhost. Sorry for the newbie questions man! Just getting used to this! – tomhallam Oct 12 '13 at 13:42
  • Didnt help im afraid. :( – tomhallam Oct 12 '13 at 14:14
  • You need to read about those options and configure mailboxes with it. – Halfgaar Oct 12 '13 at 14:19

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.