I am learning to set up a mailserver. I got it working with postfix, now trying the same configuration with Exim. How can I force a client to take up only STARTTLS connection for SMTP outgoing connection? I followed the instructions in this question.

Require STARTTLS for sending email in exim

My config looks now as following

MAIN_TLS_CERTIFICATE = /etc/ssl/certs/ssl-cert-snakeoil.pem
MAIN_TLS_PRIVATEKEY = /etc/ssl/private/ssl-cert-snakeoil.key

# Defines what hosts to 'advertise' STARTTLS functionality to. The
# default, *, will advertise to all hosts that connect with EHLO.
tls_advertise_hosts = MAIN_TLS_ADVERTISE_HOSTS

auth_advertise_hosts = ${if eq{$tls_in_cipher}{}{}{*}}

Restarted Exim, no errors. Then I ran some tests in http://checktls.com/

The TestSender passed, I could send email under secure communication. But TestSenderAssureTLS failed, the website could negotiate an unencrypted communication.

What am I missing?

When I create an account with Thunderbird, it autodetects an unsecure SMTP channel, not one with STARTTLS. Setting up the account and sending email succeeds. However, when I make an SMTP conversation from the shell of a computer in the network, no authentication is advertised. It looks as follows:

EHLO <subdomain>.<domain>
250-betelgeuse Hello <subdomain>.<domain> []
250-SIZE 52428800
250 HELP
503 AUTH command used when not advertised

Could somebody point me to what I am missing, how I can make better tests? On a related topic, how I can advertise the configuration I wish to the clients doing autdetect? Thank you.

2 Answers 2


A STARTTLS connection needs to start unsecured. The STARTTLS option is not advertised until after the first EHLO command. If you want to enforce STARTTLS you will need to add or modify an ACL. I published the Email Policy I apply.

If this server is your MX, you should not enforce STARTTLS on all connections. My configuration requires STARTTLS for connections requiring AUTH. This does not include connections from my LAN, but does apply to users sending email from my server while roaming. I also require authentication occurs on the submission port. This is the basics of the ACL I use.

# This access control list is used after an auth command.

# Deny authentication on unencrypted links
  !encrypted = *
  message = AUTH encryption is required

# Deny if AUTH isn't on submission port (autolist enabled)
   !condition = ${if eq {$interface_port}{587}}
   message = AUTH requires submission port

# Accept if encrypted (should not get here if unencrypted)
  encrypted = *

# Default deny deny message = AUTH not accepted

You could also enforce TLS in a mail ACL. This ACL allows external senders to send mail in.

# This access control list is used for every MAIL FROM command in an
# incoming SMTP message. 

# Accept if locally trusted hosts
  hosts = : +relay_from_hosts

# Accept if authenticated
## May want to check domain is local
  authenticated = *

# Accept the null sender - bounce messages and receipts
  senders = :

# Accept if not local domain - recipient ACL will handle relaying
# More checks on sender in recipient ACL.
  !hosts = : +relay_from_hosts
  !sender_domains = +local_domains

# Default deny
  message = $sender_address is not authorized to send email on this connection.

You should consider using defer instead of deny while testing the ACLs. The ACLs are enabled by adding acl statements to the main section of the configuration, and the above ACLs to the ACL section.

acl_smtp_auth = acl_local_auth acl_smtp_mail = acl_local_mail_from


According to your settings...

tls_advertise_hosts = MAIN_TLS_ADVERTISE_HOSTS
auth_advertise_hosts = ${if eq{$tls_in_cipher}{}{}{*}}

you require TLS connection to advertise authentication so initiate a connection with openssl:

openssl s_client -connect hostname:25 -starttls smtp

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.