1

I am trying to set my SMTP server so it allows only SMTP authenticated users to send emails but the actual sending is done via Mailjet. I am running on Ubuntu 14.04 LTS and Postfix version is mail_version = 2.9.6

If client authenticates with credentials - they are verified (if they are invalid the message is rejected). But clients can still send mails if they don't authenticate.

Please note that I am trying to send emails to all domains. Not just restricted list.

How can I deny all non-authorized users?

main.cf

# 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_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=no
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache


smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = mail2.xxx.cz
broken_sasl_auth_clients = yes
#smtpd_tls_auth_only = no

smtpd_delay_reject = yes
#smtpd_client_restrictions = permit_sasl_authenticated, reject


smtpd_recipient_restrictions = permit_sasl_authenticated, reject_unauth_destination, permit_mynetworks, check_r$

#permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination
#permit_sasl_authenticated,
#   reject_unauth_destination,
#   permit_mynetworks,
#   check_relay_domains

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = sweetparadise.cz
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_alias_domains = domain1.cz domain2.cz domain3.cz
alias_database = hash:/etc/aliases
myorigin = /etc/mailname

relayhost = [in-v3.mailjet.com]:587

mynetworks = 127.0.0.0/8 192.168.137.1 [::ffff:127.0.0.0]/104 [::1]/128
home_mailbox=Maildir/

smtp_tls_security_level = encrypt
Vojtech B
  • 111
  • 3
  • *But clients can still send mails if they don't authenticate.* ---> show the proof (i.e. by posting maillog entry when client send email) – masegaloeh Oct 12 '16 at 10:28

1 Answers1

0

So the problem was that I was using port forwarding from a windows host machine to a VM running the postfix. Therefore all traffic went through 192.168.137.1. This resulted in emails originating within permit_mynetworks so all were accepted.

Vojtech B
  • 111
  • 3