Setting up Mailgun or Sendgrid as Smarthost for sending email

I googled and searched Interworx docs, but i wasn’t able to find any tutorials or docs about this. Can we set a smarthost for mail sending in Interworx?


Yes it’s called smtp route

Nodeworx, services, mail, mta smtp routes

You can set it to all or domain or user email

Many thanks


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


@iworx-brandon - sorry I may have been thinking over something else re email user but certainly for domains or entire server it is correct, and if domains, can be set to route to different smarthosts (on any port with or without authentication credentials - you just tell it the smarthost to use with port and authentictation for each domain)

This post probably makes it clearer and it was some time ago, but still works today.

Also worth mentioning that the domain does not need to be a siteworx account on server, it coudl easily be or or etc… and will route these to smarthost you tell it too

Many thanks


SMTP Routes / Smarthost not working - NodeWorx / General Discussion - Interworx Forum


I think we might be talking about two separate things. Normally people want to setup smtp routes so that all email coming from their SiteWorx domain goes through a smarthost. This can help them catch spam and reduce issues with IP reputation, etc.

As described in your link to the previous forum post, you can set different smtp routes for different receiving domains (i.e. the domains you are sending to), but I don’t know of any way to do so for the domain that the email is sending from.

So you can say "all email bound for should go through" you cannot say "all email FROM should go through". These are two very distinct things.

Setting the smtp route to a “wildcard” receiving domain is basically tricking the system into letting us route everything through the smarthost. For example:

The above is really just saying “all mail being sent to ANY receiving address should be sent through the smarthost.” Which is a long-handed way of saying “all email from this server should be sent through the smarthost”. This breaksdown if you do something like:

because the emails are routed based on who the email is to. If sends an email, it’s just going to go through the localhost mail server and never touch the smarthost. The only emails that would ever get sent through the smarthost would be emails from the server to addresses.

It looks like there might be some functionality to found out of using senderroutes, but the documentation from Qmail is sparse and these routes are not managed by InterWorx at all and so for a server that is adding/removing accounts with any regularity, it could become a nightmare to manage (additionally this specifically disallows the use of smtp routes as those get processed first before the senderroute can be processed).

I hope that helps.