[Advice needed] Self-hosted Mail Server

Yeah but in Portugal is moronic.
Portuguese companies* are forced to provide/upload a monthly copy (via a XML file) of all the invoices of the past month.
So the state already know what you sold, what you bought, to whom, from whom, at what price, discount, units, descriptions, taxes yada yada yada.
Forcing the companies to keep paper records as well as digital records is just unnecessary costs for he companies.

*There are exceptions, like self employed with less than X invoices and X revenues per year.

1 Like

We downloaded the original module for WHMCS, from Moloni (an invoicing system) and basically, fully modified it to support moss and many other stuff.

1 Like


This, basically.

Have you heard of MailCow or MailInABox? MailCow is pretty much a batteries included stack that runs really well for small to medium volumes. It’s OSS and on GitHub so the code is public.

1 Like

Will take another look, thanks!

Talk to me about smarthosts… :wink:

What do you want to know?

How selective can I be? Can I say “all emails going to *@outlook.com go via SES, all emails going to *@gmail.com go via SendGrid, if bounce send via Mailchannels” for example?

I assume you are using Postfix. Look into transport_maps.

Configure Postfix to support custom outgoing email routing:

# Destination-based outgoing routing table
transport_maps = hash:/etc/postfix/transport

# SES Authentication stuff
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = encrypt
header_size_limit = 4096000
smtp_tls_note_starttls_offer = yes

Configure your routing:

@outlook.com	[email-smtp.eu-west-1.amazonaws.com]:587

Rebuild transport database (do this after every change of /etc/postfix/transport file):

$ postmap /etc/postfix/transport

Setup SES relay credentials:

[email-smtp.eu-west-1.amazonaws.com]:587 username:password

Rebuild sasl_passwd database (do this after every change of /etc/postfix/sasl_passwd file):

$ postmap /etc/postfix/sasl_passwd

And finally restart Postfix, as we have done changes to the main.cf file.
Tadaa, all email destined to @outlook.com will (or at least should!) go via SES EU.

Not sure about the bounce thing. It could be possible, but I don’t know how.

You can also route based on local source address, e.g. I host email for client.com and freebie.com. I want all emails from @client.com routed via SES, but I don’t care about @freebie.com, so their emails will go directly from the server. That’s done using sender_dependent_relayhost_maps

1 Like

Mailcow. Hell you can set up the outbound relay in the interface.

Seriously? I think this is a project for a VM next weekend!

Thanks, this is really helpful! Great to know I have that level of flexibility!