Download raw body.
smtpd mda set ORIGINAL_RECIPIENT
Hi
Thanks for the feedback. I have updated the patch.
Philipp
diff --git a/usr.sbin/smtpd/mda_unpriv.c b/usr.sbin/smtpd/mda_unpriv.c
index 1d59550aead..d2e67f66164 100644
--- a/usr.sbin/smtpd/mda_unpriv.c
+++ b/usr.sbin/smtpd/mda_unpriv.c
@@ -28,7 +28,7 @@ mda_unpriv(struct dispatcher *dsp, struct deliver *deliver,
const char *pw_name, const char *pw_dir)
{
int idx;
- char *mda_environ[11];
+ char *mda_environ[12];
char mda_exec[LINE_MAX];
char mda_wrapper[LINE_MAX];
const char *mda_command;
@@ -54,6 +54,7 @@ mda_unpriv(struct dispatcher *dsp, struct deliver *deliver,
xasprintf(&mda_environ[idx++], "PATH=%s", _PATH_DEFPATH);
xasprintf(&mda_environ[idx++], "DOMAIN=%s", deliver->rcpt.domain);
xasprintf(&mda_environ[idx++], "HOME=%s", pw_dir);
+ xasprintf(&mda_environ[idx++], "ORIGINAL_RECIPIENT=%s@%s", deliver->rcpt.user, deliver->rcpt.domain);
xasprintf(&mda_environ[idx++], "RECIPIENT=%s@%s", deliver->dest.user, deliver->dest.domain);
xasprintf(&mda_environ[idx++], "SHELL=/bin/sh");
xasprintf(&mda_environ[idx++], "LOCAL=%s", deliver->rcpt.user);
diff --git a/usr.sbin/smtpd/smtpd.conf.5 b/usr.sbin/smtpd/smtpd.conf.5
index 257ad172dc4..3544d21382a 100644
--- a/usr.sbin/smtpd/smtpd.conf.5
+++ b/usr.sbin/smtpd/smtpd.conf.5
@@ -1113,6 +1113,30 @@ For example, with recipient
.It %{rcpt} Ta expands to Dq user+t:g@example.org
.It %{rcpt:raw} Ta expands to Dq user+t?g@example.org
.El
+.Ss MDA ENVIRONMENT
+When a MDA is invoked, smtpd will create a new process.
+Only the uid and gid of the destination user is set.
+The following environment variables will be set:
+.Bl -tag -width "ORIGINAL_RECIPIENT"
+.It Ev DOMAIN
+The recipient domain
+.It Ev HOME
+The home directory of the destination user
+.It Ev RECIPIENT
+The address of the final recipient
+.It Ev ORIGINAL_RECIPIENT
+The address of the original recipient
+.It Ev EXTENSION
+The sub address of the recipient (only set when the recipient has a sub address)
+.It Ev SENDER
+The address of the sender (might be empty)
+.El
+.Pp
+This process gets the mail piped to
+.Xr stdin 3 .
+A mail is considered as delivered when the mda exit with EX_OK and
+.Xr stdin 3
+is completely read.
.Sh FILES
.Bl -tag -width "/etc/mail/smtpd.confXXX" -compact
.It Pa /etc/mail/smtpd.conf
smtpd mda set ORIGINAL_RECIPIENT