mjl- / mox

modern full-featured open source secure mail server for low-maintenance self-hosted email
https://www.xmox.nl
MIT License
3.38k stars 89 forks source link

Steps to make mox use an external SMTP service #105

Open jsfan3 opened 6 months ago

jsfan3 commented 6 months ago

This discussion is related to: https://github.com/mjl-/mox/issues/36

My VPN provider refuses my request to unblock the SMTP port.

What are the steps to make mox use the external SMTP of Brevo? These are the details:

SMTP server: smtp-relay.brevo.com Port: 587 (unencrypted connection) Login: francesco@... Password: ...

Alternatively, it's possible to use port 465 with SSL or TLS encryption.

Thanks for your great work and support.

mjl- commented 6 months ago

My VPN provider refuses my request to unblock the SMTP port.

What are the steps to make mox use the external SMTP of Brevo? These are the details:

SMTP server: smtp-relay.brevo.com Port: 587 (unencrypted connection) Login: @.*** Password: ...

Alternatively, it's possible to use port 465 with SSL or TLS encryption.

You would have to configure a "Transport" in mox.conf. See "# Transport" in https://pkg.go.dev/github.com/mjl-/mox/config. It will look something like this:

Transports: Brevo:

Submission SMTP over a TLS connection to submit email to a remote queue.

    # (optional)
    Submissions:
        # Host name to connect to and for verifying its TLS certificate.
        Host: smtp-relay.brevo.com

        # If set, authentication credentials for the remote server. (optional)
        Auth:
            Username: ***@***.***
            Password: ...

Then you would reference the transport in domains.conf as a route:

Routes:

    Transport: Brevo

I'm interesting in hearing if this works properly. I've tried this with AWS SES, but it had issues: SES overwrites the message-id, invalidating any DKIM signatures. SES also complains about "duplicate dkim-signature" headers (it is totally fine an email to have multiple dkim-signature headers). And it also doesn't support smtputf8, so some messages couldn't be sent (probably not an issue with most messages). These issues are likely/hopefully specific to AWS SES, but other providers may have these or other problems too.

jsfan3 commented 6 months ago

I have tested your suggested configuration for sending emails to

In Outlook, I have added a filter to prevent my emails from being considered spam. In any case, since Protonmail and Gmail do not complain, I would say that the test is passed.

In conclusion, Brevo's free plan seems to work fine. I hope it continues to work without any nasty surprises in the coming days and months.

mjl- commented 6 months ago

Good to hear, thanks for the feedback!

Perhaps there is an indication in the outlook Received header about why the message was marked as junk. And if you hadn't already added the brevo IPs to your domain's SPF record, doing that may serve as a positive signal for outlook (though the downside is that any other email sent through their IPs would pass your domain's DMARC policy).

jsfan3 commented 6 months ago

I was just using a free Microsoft 365 plan to test Outlook. It is actually a platform I am not familiar with and I found no information as to why the email was considered junk.

For now, I prefer to leave everything as it is and not touch the DNS configuration, which I found very difficult to enter. Incidentally, I was only able to enter part of it, as I use a NoIP domain and there are limits to the number of DNS records that can be entered. However, my mox test mailbox works for sending and receiving.

Soon I will find out if mox can handle more than 200GB of emails. My intention is to use some of the mox IMAP accounts as backups for other existing accounts.

mjl- commented 6 months ago

For now, I prefer to leave everything as it is and not touch the DNS configuration, which I found very difficult to enter.

Is this by any chance because you had to type or copy/paste them into individual text fields in a web interface? I've heard of people having a hard time because of that. It seems uncommon to have a "zone import file" function in DNS web editors... If it's something else, perhaps something can be done about it.

Soon I will find out if mox can handle more than 200GB of emails.

I'm interested in hearing how that goes, especially if that goes into a single account. Any limitations are likely more around number of messages than around the total size of the messages. When importing these messages, you will probably have to import them in batches because of current database limitations (of both memory use and cpu use). I've imported messages in batches of 100k messages on modest hardware.

jsfan3 commented 6 months ago

Yes, I had to type DNS records into individual text fields in a web interface. Anyway, the main problem is that the maximum number of DNS records allowed is too small. However, considering that using a NoIP subdomain to send and receive email is a bit of a stretch, it is a miracle that it works.

As for synchronizing the 200GB of email to mox, I will let you know.