Open dazoot opened 2 years ago
It's actually in an in-between state. The email contents have been stored, but the required queue data info has not. After message:queue
you would also get queue:route
. You can detect when a message has been completely processed by using the log:entry
hook with entry.action==='QUEUED'
like here
I still think the documentation is missleading.
We had a script to slow down users sending huge attachments, which proved not work as expected because the mail was already stored when the hook was reached :)
We were throttling AFTER the body (huge) was saved (the thing we were trying to avoid).
Well, I'm not sure what would be the best solution for you. Once the SMTP clients issues that DATA command you must process the incoming email stream in full. Until the client has not issued that command, there could still be some routing-specific commands coming (RCPT TO
).
I guess, you should probably use 'message:store'
for this use case. It's issued immediately after DATA
.
From the plugin docs:
'message:store'
- issued after DATA, before message content'message:queue'
- issued after DATA and message content, before setting up final delivery routingI guess if you want to reject and not store a message, you could create a plugin for 'message:store'
that redirects email content to /dev/null
and once the message has been processed, returns a 4xx error for the client. ZoneMTA would still "receive" the full message, but the message would not be stored anywhere.
Our hack was to send SIZE in RCPT_TO
and rewrite envelope.to
in the plugin.
But this issue is for updating the docs to not make people think that the plugin is ran before the message is stored to the queue (mongo). This mention that the plugin is ran before storing to queue confused us a lot since the size limitation we did was not working.
Maybe we can mention the details in the docs, that the message body is actually stored to the queue to make it clear.
In the plugins page the
message:queue
is advertised as running BEFORE the message is stored to the queue. By checking the code i think it runs AFTER hence thequeue.removeMessage
call in case of error.Am i wrong ? @andris9