commit 7bb76d658a1c4c378de67f8708ac4ebf8dbb557f from: Martijn van Duren via: Omar Polo date: Fri Mar 20 09:58:36 2026 UTC With both osmtpd_register_filter_mailfrom, and osmtpd_local_message the filter gets called before the tx-begin callback, resulting in that the message-specific context gets allocated too late. Call the alloc callback also from filter context if applicable and simply skip in tx-begin report. commit - 1a5c543c8a22af0430f2be05666dd5b100f9df8f commit + 7bb76d658a1c4c378de67f8708ac4ebf8dbb557f blob - 99c382cadf90978f44b08bfc294f4976ffef2b19 blob + ee9baeddee5d75e361dcdf83556384362d8207ca --- opensmtpd.c +++ opensmtpd.c @@ -1365,6 +1365,11 @@ osmtpd_onearg(struct osmtpd_callback *cb, struct osmtp { int (*f)(struct osmtpd_ctx *, const char *); + if (oncreatecb_message != NULL && cb->phase == OSMTPD_PHASE_MAIL_FROM) { + session->ctx.local_message = oncreatecb_message(&session->ctx); + if (session->ctx.local_message == NULL) + session->status = SESSION_ERROR; + } if ((f = cb->cb) != NULL && session->status == SESSION_OK) if (f(&session->ctx, line)) session->status = SESSION_ERROR; @@ -1630,7 +1635,7 @@ osmtpd_tx_begin(struct osmtpd_callback *cb, struct osm if (!cb->storereport) session->ctx.msgid = 0; - if (oncreatecb_message != NULL) { + if (oncreatecb_message != NULL && session->ctx.local_message == NULL) { session->ctx.local_message = oncreatecb_message(&session->ctx); if (session->ctx.local_message == NULL) session->status = SESSION_ERROR;