I've got a PHP web app set up which, when a user submits the form, sends an acknowledgement email from username@domainname.co.uk, and also sends details of their enquiry from the same email address to a predefined mailbox. It's running on a Debian Wheezy server.

In development I was using a Gmail account with MSMTP, which was easy to set up and worked fine. However, we're going live soon and I want to configure it to send via the existing mail server for that domain. However, the mail server uses MS Exchange, and a Google search hasn't shown up much on using Exchange with MSMTP.

Ideally I'd like to just amend the MSMTP config so that it can send emails via the existing Exchange, much like I was already doing, but I can't seem to get it configured correctly. Here's my /etc/msmtprc:

    # ------------------------------------------------------------------------------
    # msmtp System Wide Configuration file
    # ------------------------------------------------------------------------------

    # A system wide configuration is optional.
    # If it exists, it usually defines a default account.
    # This allows msmtp to be used like /usr/sbin/sendmail.

    # ------------------------------------------------------------------------------
    # Accounts
    # ------------------------------------------------------------------------------

    # Main Account
    tls on
    tls_starttls on
    tls_trust_file /etc/ssl/certs/ca-certificates.crt

    account username@domainname.co.uk
    host domainname.co.uk
    port 25
    #auth on
    from username@domainame.co.uk
    user username
    password password
    logfile /var/log/msmtp.log

    # ------------------------------------------------------------------------------
    # Configurations
    # ------------------------------------------------------------------------------

    # Construct envelope-from addresses of the form "user@oursite.example".
    #auto_from on
    #maildomain fermmy.server

    # Use TLS.
    #tls on
    #tls_trust_file /etc/ssl/certs/ca-certificates.crt

    # Syslog logging with facility LOG_MAIL instead of the default LOG_USER.
    # Must be done within "account" sub-section above
    #syslog LOG_MAIL

    # Set a default account

    # ------------------------------------------------------------------------------

Here is the error message I get in /var/log/msmtp.log:

Sep 23 11:34:44 host=username.co.uk tls=on auth=on user=username from=username@domainname.co.uk recipients=myusername@mydomain.com errormsg='the server does not support TLS via the STARTTLS command' exitcode=EX_UNAVAILABLE

Can anyone point out where I have gone awry with this? I suppose it's possible I might be better off installing Postfix, setting that up as a null client, and adding the server to the MX records, but I would prefer to do it this way so the sent emails are retained by the Exchange server.


the server does not support TLS via the STARTTLS command

There's your error...so it would seem that your Exchange server isn't setup properly for TLS.

  1. Telnet to the Exchange server on port 25

  2. Enter ehlo, If “250-STARTTLS” is listed in the response, Opportunistic TLS is offered.

If not, you'll need to enable TLS on the receive connector:

Set-ReceiveConnector “ReceiveConnectorName” –DomainSecureEnabled $true –AuthMechanism TLS

However, understand what you are doing first, as the Receive connector might be used for other inbound traffic and it won't FORCE TLS so read the following Technet article FIRST!

See here for more information on setting up mutual TLS on Exchange: http://technet.microsoft.com/en-us/library/bb123543.aspx

Otherwise you can disable TLS in MSMTP if you'd like.

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.