Skip to main content

How to deliver using LMTP

The Halon platform supports LMTP delivery via the Try() function. It enables you to create setups with only Halon and an email storage server, such as Dovecot. Consequently, all filtering, routing, rewriting and forwarding takes place in the Halon.

Dovecot example

Normally, you have an MTA such as Postfix in front of Dovecot that does alias expansion. When delivering messages directly to Dovecot with LMTP, it's important to understand that Dovecot only accepts messages to actual mailboxes, not aliases. Therefore, the alias expansion (if any) needs to take place in the Halon. Below is an example of how this can be done, using a REST API that feeds the Halon system that information.

Create an API that returns something like this as response to an "email alias" query such as [email protected]. Then add an include file with a function called lookup_aliases that perform API calls against the API.

[
"john",
"bob",
"smith"
]

Then in Halon use the following script to query each recipient, and deliver to all aliases on that list. If the aliases resolving is more complex and may include multiple destination servers, the API will need to be extended as well as the code in Halon.

Make sure the transport profile lmtpserver in Halon is set to use LMTP.

EOD context
$transactionid = $transaction["id"];
$sender = $transaction["senderaddress"];
$recipients = $transaction["recipients"];
$mail = $arguments["mail"];

$aliases = [];
foreach ($recipients as $recipient)
{
$request = lookup_aliases($recipient["recipient"]);
if (!$request)
Defer("Could not lookup recipient");
$aliases += $request;
}

foreach ($aliases as $alias)
$mail->queue($sender, $alias, "lmtpserver");
Accept();