commit e9c82584484ebdc9301f35e40018460e153a4f6d from: Martijn van Duren date: Thu Mar 19 14:16:56 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 - 864d611e31f16a48bbbbaf2678af4422d92200f0 commit + e9c82584484ebdc9301f35e40018460e153a4f6d 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;