Proxmox with mailgun

I go through changing the mail relay settings on a linux server (Proxmox) and the issues I encountered along the way.

Email icon.
Photo by Brett Jordan / Unsplash

Hey everyone, this one will be a quickie! (after the very long previous post)

After setting up Pterodactyl, Unraid and Ghost to use mailgun for sending mail notifications, and after getting burned badly by misconfigured (no retention policy :/ ) backups on Proxmox, I decided to use it with the proxmox scheduled backups as well.

It was a relatively simple affair, with only a few small snags, but I decided to make this post anyways, as I was dealing with a few completely new things (to me): Postfix, mail logs and mail on Linux.

At first I thought this was going to be dead easy, just look up the proxmox docs about mail and that's it, right? Not really, as there surprisingly isn't any documentation about the Proxmox mail system. (others are as surprised as I am)

After some digging, I found out Proxmox uses Postfix for sending mail, and I searched for the first blog which would describe how to use Postfix to send relay mail to Mailgun, and found this.

Postfix Documentation

The configuration file was stored in etc/postfix/ and was clearly labeled and easy to access. I added the following configuration and restarted with systemctl restart postfix.

relayhost =
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps =
smtp_sasl_security_options = noanonymous
Turns out this isn't working.

The first thing: it wasn't happy about the relayhost property, as it was already defined somewhere else in the config and I just appended this at the end. The second problem was a bit trickier: it just didn't send mail when I used the sendmail command.

I googled around for a bit, and found out there's a log file dedicated for sending/receiving mail! You can see all about your mail processes with cat /var/log/mail.log. I went digging around the logs and found out it wasn't authenticating with the mail server: were my credentials wrong? Turns out they weren't even on that server, but on another one entirely. My SMTP server was supposed to be instead of just

Screenshot of test email.
The test mail succeeded!

The lesson learned: don't just blindly copy and paste configs, even if they do seem appropriate for your use case. There may be some small errors hidden inside! Always check the configs before uploading.

The next post will be either about my new Proxmox node and how I set up my two-node cluster, or about a Moodle installation that took unexpectedly long to set up.

See ya!

Addendum: writing up documentation a week or month after the process invariably leads to small errors. This time, I found the error rather quickly - when installing my new Proxmox node. I set the mail up with the instructions written above and couldn't get it to work. I forgot to mention a major error I was dealing with and how I solved it - warning: SASL authentication failure: No worthy mechs found.

This error appears on hosts without the libsasl2-modules. The solution is rather easy after figuring out the problem - just install the package with apt.