|mit...@bitblock.net||May 27, 2014 10:59 am|
|Sam Varshavchik||May 27, 2014 3:10 pm|
|mit...@bitblock.net||May 28, 2014 1:43 am|
|Sam Varshavchik||May 28, 2014 4:03 am|
|mit...@bitblock.net||May 28, 2014 8:17 pm|
|mit...@bitblock.net||May 28, 2014 8:37 pm|
|Sam Varshavchik||May 29, 2014 4:02 am|
|mit...@bitblock.net||Jun 5, 2014 1:19 pm|
|Sam Varshavchik||Jun 5, 2014 4:53 pm|
|mit...@bitblock.net||Jun 5, 2014 5:06 pm|
|Sam Varshavchik||Jun 5, 2014 5:17 pm|
|mit...@bitblock.net||Jun 5, 2014 6:56 pm|
|Subject:||Re: [courier-users] Problems escaping subject line and mailbot|
|Date:||Jun 5, 2014 1:19:47 pm|
AWESOME Idea. Thanks :-) This post is just to share the completed solution for
anyone who searches later.
For those that come after me...
My issue was delivering an auto response that included the original subject in a
way that was safe. I had been trying to use the subject line I had escaped. Sam
suggested using the Subject from an environment variable but I was having
trouble getting it passed through properly.
One remaining question I had - is there any place the different response types
(-T reply vs. -T replydsn) are differentiated?
Sam had written:
When you execute the following sequence of commands:
$ echo "--" -s"Subject: ($SUBJECT)"
The resulting output is:
-- -sSubject: (foobar)
As you can see, the shell carries out variable substitution inside double-
quotes. If you can't figure this out, a workaround is to use an intermediate script
file. Sometimes when you have to execute a long, convoluted command with many variable
expansions, it's easier to put the command into a separate script file, and execute the
script file: cc "| /etc/autoreply.sh" Then, put this long invocation of mailbot into the executable /etc/autoreply.sh
file, where it gets involved with everything properly quoted. All of maildrop's variables should be available
in the environment variables.
So I did. First, I added a RAWSUBECT (unescaped) to allow existing script to
continue to use the escaped subject in my maildroprc (in certain situations I
wanted to log it which means an echo - the escaping is needed there).
/^Subject: *(.*)/ SUBJECT=escape($MATCH1) RAWSUBJECT=$MATCH1
Lower down inside a condition that looks for people on vacation, I added the
call to my script:
cc "| /usr/local/courier/etc/send-auto-reply.sh"
And finally, here is my script - the variables are assigned in my maildroprc
before calling the script.
#this is called from maildroprc
#The -D 1 means one reply per day.
#The -d sets the location of the DB to store email addresses and dates
$MAILBOT -N -D 1 -d $Maildir/BB-autoreply -t $Maildir/BB-autoreply.txt -T
replydsn -A"From: $Name <$Email>" -s"Subject: AUTO-REPLY: ($RAWSUBJECT)"
-A"Errors-To: nobody@nowhere" -A"Precedence: junk" -A"X-Loop: $BADLOOP"
/usr/local/bin/sendmail -f '' </dev/stdin
Changed the ownership / permissions to root:courier / 755.
The cc directs the message to the shell script, but the call to mailbot needs to
redirect stdin to itself in order to read the mail message - that' s what the
</dev/stdin is for - this is io redirection.
I'm still not sure what the different -T types do, but I'm happy with the result
- a safe auto response, limited to one per day, which includes the subject for
I had originally included a call to env to see the variables being passed
through. I thought it wasn't working. But I'd forgotten that I'd left the rate
limiting database options (-D 1 -d pathtodb) in place. D'oh! Keep this in mind
Thanks again Sam!
------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech
_______________________________________________ courier-users mailing list cour...@lists.sourceforge.net Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users