Skip to content

[SAAS] Remote delivery with multiple gateway issue? #2196

@Arsnael

Description

@Arsnael

Dung asked me to help check this morning why even a paying customer on twp stg platform had still his messages being delivered by the free postfix and not the premium one setup.

The conf seems fine in mailetcontainer.xml.

Checking in gmail the received message it seems it has been delivered by free postfix one.

Checking both postfix logs can confirm it goes to the free one. The user being tested has the isPaying field to true.

Checking tmail logs:

{"timestamp":"2026-02-24T03:30:51.292Z","level":"INFO","thread":"spooler-79","mdc":{"gateways":"[tmail-postfix-premium:25]","protocol":"mailetcontainer","mimeMessageId":"<Mime4j.*****>","mail":"a9a520ab-b431-44a2-b13f-4dfb444d02f3","sender":"******@stg.lin-saas.com","recipients":"[*****]","host":"localhost","action":"RemoteDelivery","mailId":"a9a520ab-b431-44a2-b13f-4dfb444d02f3","state":"relay-premium","mailet":"RemoteDelivery"},"logger":"org.apache.james.util.AuditTrail","message":"Remote delivering mail planned with gateway.","context":"default"}

That's the audit trail in RemoteDelivery mailet. It says it plans to do the remote delivery with the premium postfix gateway ("gateways":"[tmail-postfix-premium:25). Then it adds the message into the queue. Ok!

Next log:

{"timestamp":"2026-02-24T03:30:51.599Z","level":"INFO","thread":"RemoteDelivery-Process-79","mdc":{"mail":"a9a520ab-b431-44a2-b13f-4dfb444d02f3","sender":"*****@stg.lin-saas.com","recipients":"[rene.cordier@gmail.com]"},"logger":"org.apache.james.transport.mailets.remote.delivery.MailDelivrerToHost","message":"Mail (a9a520ab-b431-44a2-b13f-4dfb444d02f3) with messageId <Mime4j.*****@stg.lin-saas.com> sent successfully to tmail-postfix-out at 10.3.121.7 from beponge@stg.lin-saas.com for [*****]","context":"default"}

Here it seems MailDelivrer process picks the mail form the queue and then sends it... to postfix free (tmail-postfix-out). So something is wrong here.

From what I understand looking at the code:
https://github.com/apache/james-project/blob/master/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrer.java#L114

It seems we do a guess on the target host to deliver this... instead of just reusing the gateway configuration (which is passed along I believe when this java object is created).

Is this legacy code? Why not using the gateway configured in the mailet instead directly? Maybe could change to this? Maybe there is something at play here I dont understand though?

It seems a blocker though for multiple gateway deliveries at the moment though for saas I would say.

@chibenwa thoughts?

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingsaas

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions