Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ parse_conf(const char *config_path)
config.features |= FULLBOUNCE;
else if (strcmp(word, "NULLCLIENT") == 0 && data == NULL)
config.features |= NULLCLIENT;
else if (strcmp(word, "REPLACEFROM") == 0 && data != NULL) {
config.header_from_address = data;
}
else {
errlogx(EX_CONFIG, "syntax error in %s:%d", config_path, lineno);
/* NOTREACHED */
Expand Down
7 changes: 7 additions & 0 deletions dma.8
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ setting it to
will send all mails as
.Ql Sm off Va username @percolator .
.Sm on
.Pp
It can be useful to combine this setting with
.Sq REPLACEFROM .
.It Ic NULLCLIENT Xo
(boolean, default=commented)
.Xc
Expand All @@ -325,6 +328,10 @@ the defined
requires
.Sq SMARTHOST
to be set.
.It Ic REPLACEFROM Xo
(string, default=empty)
.Xc
Replace the message header "From" address with the given address.
.El
.Ss Environment variables
The behavior of
Expand Down
1 change: 1 addition & 0 deletions dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct config config = {
.masquerade_host = NULL,
.masquerade_user = NULL,
.fingerprint = NULL,
.header_from_address = NULL,
};


Expand Down
5 changes: 5 additions & 0 deletions dma.conf
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,10 @@
# MASQUERADE percolator will send mails as $username@percolator, e.g. fish@percolator
# MASQUERADE herb@ert will send all mails as herb@ert

# Replace the message header "From" address with the given address.
# Example:
# REPLACEFROM user@domain.local


# Directly forward the mail to the SMARTHOST bypassing aliases and local delivery
#NULLCLIENT
1 change: 1 addition & 0 deletions dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ struct config {
const char *masquerade_host;
const char *masquerade_user;
const unsigned char *fingerprint;
const char *header_from_address;

/* XXX does not belong into config */
SSL *ssl;
Expand Down
10 changes: 8 additions & 2 deletions mail.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,11 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
had_date = 1;
else if (strprefixcmp(line, "Message-Id:") == 0)
had_messagid = 1;
else if (strprefixcmp(line, "From:") == 0)
else if (strprefixcmp(line, "From:") == 0) {
had_from = 1;
if (config.header_from_address)
snprintf(line, sizeof(line), "From: <%s>\n", config.header_from_address);
}
else if (strprefixcmp(line, "Bcc:") == 0)
nocopy = 1;

Expand Down Expand Up @@ -453,7 +456,10 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
hostname());
} else if (!had_from) {
had_from = 1;
snprintf(line, sizeof(line), "From: <%s>\n", queue->sender);
if (config.header_from_address)
snprintf(line, sizeof(line), "From: <%s>\n", config.header_from_address);
else
snprintf(line, sizeof(line), "From: <%s>\n", queue->sender);
}
if (fwrite(line, strlen(line), 1, queue->mailf) != 1)
return (-1);
Expand Down