Skip to content
Browse files

queue: Add an "allmailfrom" control file, to force a fixed sender

  • Loading branch information...
1 parent 43601e4 commit da55b71b6136bcefc7aa784a7f9fd45987670a7a @bruceg committed Sep 13, 2013
Showing with 37 additions and 0 deletions.
  1. +3 −0 NEWS
  2. +4 −0 doc/nullmailer-queue.8
  3. +4 −0 src/queue.cc
  4. +26 −0 test/tests/queue/rewrite
View
3 NEWS
@@ -2,6 +2,9 @@ This file lists all the major user-visible changes to nullmailer.
-------------------------------------------------------------------------------
Changes in version 1.14
+- Added an "allmailfrom" control file to nullmailer-queue, causing all
+ messages to share a hard-coded envelope sender.
+
- Improved handling of system errors when reading config files.
Development of this version has been sponsored by FutureQuest, Inc.
View
4 doc/nullmailer-queue.8
@@ -29,6 +29,10 @@ This is provided to allow local daemons to be able to send email to
"somebody@localhost" and have it go somewhere sensible instead of
being bounced by your relay host. To send to multiple addresses, put
them all on one line separated by a comma.
+.TP
+.B allmailfrom
+If this file is not empty, its contents will override the envelope
+sender on all messages.
.SH OTHER FILES
.TP
.B /var/nullmailer/queue
View
4 src/queue.cc
@@ -41,6 +41,7 @@ pid_t pid = getpid();
uid_t uid = getuid();
time_t timesecs = time(0);
mystring adminaddr;
+mystring allmailfrom;
bool is_dir(const char* path)
{
@@ -84,6 +85,8 @@ bool validate_addr(mystring& addr, bool recipient)
mystring hostname = addr.right(i+1);
if (recipient && !!adminaddr && (hostname == me || hostname == "localhost"))
addr = adminaddr;
+ else if (!recipient && !!allmailfrom)
+ addr = allmailfrom;
else if(hostname.find_first('.') < 0)
return false;
return true;
@@ -185,6 +188,7 @@ int main(int, char*[])
adminaddr = adminaddr.subst(',', '\n');
read_hostnames();
}
+ config_read("allmailfrom", allmailfrom);
if(!deliver())
return 1;
View
26 test/tests/queue/rewrite
@@ -10,6 +10,10 @@ que-recip() {
set -e
que | sed -e '2,/^$/!d' | grep -q "$@"
}
+que-sender() {
+ set -e
+ que | head -n 1 | grep -q "$@"
+}
echo admin@remote >/tmp/nm/etc/nullmailer/adminaddr
@@ -54,3 +58,25 @@ header
data
EOF
+
+echo "Checking that queue transmits the envelope sender normally."
+que-sender '^bruceg@qcc.sk.ca$' <<EOF
+bruceg@qcc.sk.ca
+user@localhost
+
+header
+
+data
+EOF
+
+echo "Checking that queue rewrites sender with allmailfrom."
+echo sender@remote3 >/tmp/nm/etc/nullmailer/allmailfrom
+que-sender '^sender@remote3$' <<EOF
+bruceg@qcc.sk.ca
+user@localhost
+
+header
+
+data
+EOF
+rm -f /tmp/nm/etc/nullmailer/allmailfrom

0 comments on commit da55b71

Please sign in to comment.
Something went wrong with that request. Please try again.