2

I'm running mail server on Ubuntu 12.04 and box has Web Server + Mail Server (Postfix + Dovecot). This is Virtual Machine setup on Windows Azure cloud.

Problem: I'm unable to send emails outside network. Following are the configuration and logs.

Postfix:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
dovecot_destination_recipient_limit = 1
inet_interfaces = all
mailbox_size_limit = 0
mydestination = abc.cloudapp.net, localhost.abc.cloudapp.net, localhost
myhostname = abc.cloudapp.net
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
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 = mysql:/etc/postfix/mysql-virtual-alias-maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_transport = dovecot

Dovecot:

# 2.0.19: /etc/dovecot/dovecot.conf
# OS: Linux 3.2.0-65-virtual x86_64 Ubuntu 12.04.4 LTS ext4
auth_mechanisms = plain login
mail_location = maildir:/var/vmail/%d/%n/Maildir
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date ihave
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
plugin {
  sieve = ~/.dovecot.sieve
  sieve_dir = ~/sieve
}
protocols = " imap sieve pop3"
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
  }
  unix_listener auth-userdb {
    group = vmail
    user = vmail
  }
}
ssl_cert = </etc/ssl/certs/mailserver.pem
ssl_key = </etc/ssl/private/mailserver.pem
userdb {
  args = uid=vmail gid=vmail home=/var/vmail/%d/%n
  driver = static
}
protocol lda {
  mail_plugins = " sieve"
}

/var/log/mail.log

Jul  9 08:40:11 layfootak postfix/smtpd[44127]: connect from unknown[87.109.35.199]
Jul  9 08:40:12 layfootak postfix/smtpd[44127]: NOQUEUE: reject: RCPT from unknown[87.109.35.199]: 554 5.7.1 <raheel@layfootak.com>: Relay access denied; from=<abc@example.com> to=<abc@otherdomain.com> proto=ESMTP helo=<[127.0.0.1]>

I'm able to configure and get emails properly with Mozilla Thunderbird email client. It shows my inbox properly but when I'm sending an email to other email address like outside network then it gives Relay access denied; from= to= proto=ESMTP helo=<[127.0.0.1]>

Please advise me.

I've fixed the Problem after setting up following postfix configuration for SMTP Relaying configuration:

sudo postconf -e smtpd_sasl_type=dovecot
sudo postconf -e smtpd_sasl_path=private/auth
sudo postconf -e smtpd_sasl_auth_enable=yes
sudo postconf -e smtpd_tls_security_level=may
sudo postconf -e smtpd_tls_auth_only=yes
sudo postconf -e smtpd_tls_cert_file=/etc/ssl/certs/mailserver.pem
sudo postconf -e smtpd_tls_key_file=/etc/ssl/private/mailserver.pem
sudo postconf -e smtpd_recipient_restrictions=" \
  permit_mynetworks \
  permit_sasl_authenticated \
  reject_unauth_destination"
1
  • 1
    For you test, do you have Thunderbird on the same machine as Postfix ? In final, do you want to use only Thunderbird to send mail or do you plan to install a web mail solution to do this ?
    – Justin
    Jul 9, 2014 at 9:03

1 Answer 1

1

Sending mail to domains not hosted on your Postfix (external mails thus) is only possible for IP and networks allowed to do relaying by the configuration of Postfix.

In Postfix, this is achieved by giving these allowed IP's and networks to the mynetworks configuration directive in main.cf.

In your case, it shows that only localhost is allowed to relay mail outside your Postfix installation.

To allow you to send mail outside without making your server an open relay you should at least add the IP of the clients that need to send external mails.

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 A.B.C.D/32

Note the /32 after the IP address, this is to be sure that Postfix will not allow the whole subnet but just that particular address.

If all the clients are on the same subnet, you can configure (example: all your clients are connected to a 192.168.1.0 network with 255.255.255.0 as mask) :

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

Of course, if you plan to install a webmail based software for your users, the only allowed host to send & relay mail would be the web server itself. In this case, you don't have to modify the configuration of Postfix but be sure that your web mail solution use 127.0.0.1 as SMTP server.

1
  • Problem was not related with mynetworks configuration. I made some configuration for Relaying SMTP and Authentication for Postfix.
    – user379367
    Jul 9, 2014 at 10:29

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.