Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 (mail2.bahnhof.se) 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 mail2.bahnhof.se 25
Connected to mail2.bahnhof.se.
helo mail.mydomain.com
250 mxf2.bahnhof.se
mail from: user11@mail.mydomain.se
250 Ok
rcpt to: user11@gmail.com
250 Ok
data
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 mail.mydomain.com 25
HELO mail.mydomain.com
250 mail.mydomain.com
mail from: user11@mail.mydomain.com
250 2.1.0 Ok
rcpt to: user11@gmail.com
554 5.7.1 <user11@gmail.com>: Relay access denied

My postfix configuration (main.cf):

# 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

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

Any ideas what can be wrong?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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

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

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

mynetworks = 192.168.0.15 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128

In case you telnet client's IP is 192.168.0.15

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).

share|improve this answer
    
Thank you! That solved it. I thought that 127.0.0.0 was sufficient as I was telneting from localhost. –  Pithikos May 10 '14 at 13:27
    
But you wrote "telnet mail.mydomain.com 25" and probably your telnet client bound it's socket to your local IP instead of local loopback (127.0.0.1). You can check that by doing "telnet 127.0.0.1 25" without adding the IP to my networks. –  drk.com.ar May 10 '14 at 13:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.