-/* $OpenBSD: delivery_lmtp.c,v 1.13 2015/10/27 21:11:27 jung Exp $ */
+/* $OpenBSD: delivery_lmtp.c,v 1.14 2015/10/27 21:20:11 jung Exp $ */
/*
* Copyright (c) 2013 Ashish SHUKLA <ashish.is@lostca.se>
lmtp_open(struct deliver *deliver)
{
FILE *fp;
- char *buf = NULL, hn[HOST_NAME_MAX+1], *to = deliver->to;
+ char *buf = NULL, hn[HOST_NAME_MAX + 1],
+ *rcpt = deliver->to, *to = deliver->to;
size_t sz = 0;
ssize_t len;
int s;
+ strsep(&rcpt, " ");
s = (to[0] == '/') ? unix_socket(to) : inet_socket(to);
if ((fp = fdopen(s, "r+")) == NULL)
err(1, "fdopen");
if (lmtp_cmd(&buf, &sz, '2', fp, "MAIL FROM:<%s>", deliver->from) != 0)
errx(1, "MAIL FROM rejected: %s", buf);
- if (lmtp_cmd(&buf, &sz, '2', fp, "RCPT TO:<%s>", deliver->user) != 0)
+ if (lmtp_cmd(&buf, &sz, '2', fp, "RCPT TO:<%s>",
+ rcpt ? deliver->dest : deliver->user) != 0)
errx(1, "RCPT TO rejected: %s", buf);
if (lmtp_cmd(&buf, &sz, '3', fp, "DATA") != 0)
-/* $OpenBSD: mda.c,v 1.111 2015/10/26 09:22:03 jsg Exp $ */
+/* $OpenBSD: mda.c,v 1.112 2015/10/27 21:20:11 jung Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
sizeof(deliver.user));
(void)strlcpy(deliver.from, e->sender,
sizeof(deliver.from));
+ (void)strlcpy(deliver.dest, e->dest,
+ sizeof(deliver.dest));
if (strlcpy(deliver.to, e->buffer,
sizeof(deliver.to))
>= sizeof(deliver.to)) {
-/* $OpenBSD: parse.y,v 1.154 2015/09/07 15:36:53 gilles Exp $ */
+/* $OpenBSD: parse.y,v 1.155 2015/10/27 21:20:11 jung Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
%token AS QUEUE COMPRESSION ENCRYPTION MAXMESSAGESIZE MAXMTADEFERRED LISTEN ON ANY PORT EXPIRE
%token TABLE SECURE SMTPS CERTIFICATE DOMAIN BOUNCEWARN LIMIT INET4 INET6 NODSN
-%token RELAY BACKUP VIA DELIVER TO LMTP MAILDIR MBOX HOSTNAME HOSTNAMES
+%token RELAY BACKUP VIA DELIVER TO LMTP MAILDIR MBOX RCPTTO HOSTNAME HOSTNAMES
%token ACCEPT REJECT INCLUDE ERROR MDA FROM FOR SOURCE MTA PKI SCHEDULER
%token ARROW AUTH TLS LOCAL VIRTUAL TAG TAGGED ALIAS FILTER KEY CA DHPARAMS
%token AUTH_OPTIONAL TLS_REQUIRE USERBASE SENDER MASK_SOURCE VERIFY FORWARDONLY RECIPIENT
fatal("invalid lmtp destination");
free($4);
}
+ | DELIVER TO LMTP STRING RCPTTO {
+ rule->r_action = A_LMTP;
+ if (strchr($4, ':') || $4[0] == '/') {
+ if (strlcpy(rule->r_value.buffer, $4,
+ sizeof(rule->r_value.buffer))
+ >= sizeof(rule->r_value.buffer))
+ fatal("lmtp destination too long");
+ if (strlcat(rule->r_value.buffer, " rcpt-to",
+ sizeof(rule->r_value.buffer))
+ >= sizeof(rule->r_value.buffer))
+ fatal("lmtp recipient too long");
+ } else
+ fatal("invalid lmtp destination");
+ free($4);
+ }
| DELIVER TO MDA STRING {
rule->r_action = A_MDA;
if (strlcpy(rule->r_value.buffer, $4,
{ "pki", PKI },
{ "port", PORT },
{ "queue", QUEUE },
+ { "rcpt-to", RCPTTO },
{ "recipient", RECIPIENT },
{ "reject", REJECT },
{ "relay", RELAY },
-.\" $OpenBSD: smtpd.conf.5,v 1.129 2015/09/03 12:23:23 millert Exp $
+.\" $OpenBSD: smtpd.conf.5,v 1.130 2015/10/27 21:20:11 jung Exp $
.\"
.\" Copyright (c) 2008 Janne Johansson <jj@openbsd.org>
.\" Copyright (c) 2009 Jacek Masiulaniec <jacekm@dobremiasto.net>
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\"
-.Dd $Mdocdate: September 3 2015 $
+.Dd $Mdocdate: October 27 2015 $
.Dt SMTPD.CONF 5
.Os
.Sh NAME
.Pp
Finally, the method of delivery is specified:
.Bl -tag -width Ds
-.It Ic deliver to lmtp Op Ar host : Ns Ar port | socket
+.It Xo
+.Ic deliver to lmtp
+.Op Ar host : Ns Ar port | socket
+.Op Ic rcpt-to
+.Xc
Mail is delivered to
.Ar host : Ns Ar port ,
or to the
.Ux
.Ar socket
over LMTP.
+.Pp
+Optionally,
+.Ic rcpt-to
+might be specified to use the recipient email address (after expansion) instead
+of the local user in the LMTP session as RCPT TO.
.It Ic deliver to maildir Op Ar path
Mail is added to a maildir.
Its location,