Setting up Mailgun or Sendgrid as Smarthost for sending email

This is the documentation on sending mail through an external relay. How to: Forward Mail Through an External SMTP Server — InterWorx documentation

The only caveat not covered in this documentation is that if your smarthost required authentication, you can add that information in the /var/qmail/control/smtproutes file directly after the external server declaration in setup 3. So it would look something like: username password

It’s unclear what John is referencing when he says “all or domain or user email”, but as far as I am aware, smtproutes are set for the entire server. There is no way to split route email (i.e. set one sending domain to send over a specific smarthost and another to send over another or through localhost). This is more explicitly explained in the Qmail documentation here: Smtproutes - Qmailtoaster