Zimbra SMTP Relay Through SendGrid



  • Setting up SendGrid as an SMTP Relay for Zimbra is not entirely obvious. But it can be done and is not too hard. Assuming that you have a SendGrid account already and you have made an SMTP API Key, we are ready to begin configuring Zimbra. SendGrid offers free accounts for this.

    First, we need to be the zimbra user for all of this. If you try to do this as root, you will get errors that LMDB is not supported in CentOS 7 (and many other OS releases.) This is because you need to be using Zimbra's own version of the tools, not the OS ones.

    su - zimbra
    

    Now we can begin. First we set the relay host.

    zmprov ms `zmhostname` zimbraMtaRelayHost smtp.sendgrid.net
    

    Now we need to set our password file. For SendGrid, the username for the key is called literally apikey. This is a little confusing to read.

    echo smtp.sendgrid.net apikey:your_actual_api_key > /opt/zimbra/conf/relay_password
    

    Now we need to process the map into an LMDB file.

    postmap /opt/zimbra/conf/relay_password
    

    We can test that this worked with this command.

    postmap -q smtp.sendgrid.net /opt/zimbra/conf/relay_password
    

    Now to create the map from that file.

    zmprov ms `zmhostname` zimbraMtaSmtpSaslPasswordMaps lmdb:/opt/zimbra/conf/relay_password
    

    Now we override the outgoing server name.

    zmprov ms `zmhostname` zimbraMtaSmtpCnameOverridesServername no
    

    Enable TLS

    zmprov ms `zmhostname` zimbraMtaSmtpTlsSecurityLevel may
    

    Zimbra will pick up these changes automatically within two minutes.



  • @scottalanmiller said in Zimbra SMTP Relay Through SendGrid:

    Setting up SendGrid as an SMTP Relay for Zimbra is not entirely obvious. But it can be done and is not too hard. Assuming that you have a SendGrid account already and you have made an SMTP API Key, we are ready to begin configuring Zimbra. SendGrid offers free accounts for this.

    First, we need to be the zimbra user for all of this. If you try to do this as root, you will get errors that LMDB is not supported in CentOS 7 (and many other OS releases.) This is because you need to be using Zimbra's own version of the tools, not the OS ones.

    su - zimbra
    

    Now we can begin. First we set the relay host.

    zmprov ms `zmhostname` zimbraMtaRelayHost smtp.sendgrid.net
    

    Now we need to set our password file. For SendGrid, the username for the key is called literally apikey. This is a little confusing to read.

    echo smtp.sendgrid.net apikey:your_actual_api_key > /opt/zimbra/conf/relay_password
    

    Now we need to process the map into an LMDB file.

    postmap /opt/zimbra/conf/relay_password
    

    We can test that this worked with this command.

    postmap -q smtp.sendgrid.net /opt/zimbra/conf/relay_password
    

    Now to create the map from that file.

    zmprov ms `zmhostname` zimbraMtaSmtpSaslPasswordMaps lmdb:/opt/zimbra/conf/relay_password
    

    Now we override the outgoing server name.

    zmprov ms `zmhostname` zimbraMtaSmtpCnameOverridesServername no
    

    Enable TLS

    zmprov ms `zmhostname` zimbraMtaSmtpTlsSecurityLevel may
    

    Zimbra will pick up these changes automatically within two minutes.

    Nice, I love it, it is almost as postfix since ZImbra uses postfix 🙂



  • Yup, basically just automating Postfix configs.