Sending all outgoing mails via another server

Mireka can be configured to send all outgoing mail through another server. The other server is usually the so called smarthost. This is useful for example if the local network connects to the internet through a dynamic IP address.

In contrast to proxy mode, Mireka in this case waits until it completely receives the incoming mail, stores it, and forwards them later, usually within a few milliseconds. Mireka tries to send to the configured smarthost (or smarthosts, see later), and if is not successful, it try it again later, up to the configured duration.

NOTE: If it turns out that the mail cannot be relayed for some reason, then Mireka sends a Delivery Status Notification mail back to the original sender. However, if the original sender is not a local user, this bounce mail must also go through the smarthost. If the smarthost is inaccessible for an extended time, Mireka will give up, and delete the DSN mail too. Depending on the importance of the mails this can be a dangerous situation because the mail is accepted but neither the mail is delivered, nor the user is notified. To prevent this, configure appropriate retry intervals and regularly monitor the mail error logs.

First edit mireka.js and configure the value of the backendServer variable. For example if the smarthost is myisp.example.com, listens on port 587, and requires authentication, then your configuration should look like this:

... backendServer = setup(BackendServer, { host: "myisp.example.com", port: 587, user: "mycompany", password: "CHANGEIT", }); ...

Note: you can define more than one backend servers, and reference them later.

Next, edit submission/queues.js and uncomment the indirect sender definition. Your configuration should look like this:

... immediateSender = setup(IndirectImmediateSender, { mailToHostTransmitter: mailToHostTransmitter, backendServer: backendServer, }); ...

Load balancing

It is also possible to use more than one smarthosts. Mireka provides basic load balancing using the weight and backup properties of backend servers. For example:

... upstream = setup(Upstream, { servers: [ setup(BackendServer, { host: "smtp1.example.com", weight: 60, }), setup(BackendServer, { host: "smtp2.example.com", weight: 40, }), setup(BackendServer, { host: "backup.example.com", backup: true, }), ], }); immediateSender = setup(IndirectImmediateSender, { mailToHostTransmitter: mailToHostTransmitter, upstream: upstream, }); ...