Note: please don't use richtext (fonts) in your email. Procmail is a UNIX
application, and plaintext is universally readable (well, so long as you
read latin character encodings).
At 23:17 2001-07-18 -0500, Michael McKelvey wrote:
mail comes in to my account, with a line in the body that looks like this
(there's other info too, but that's the pertinent line):
Email:foo(_at_)bar(_dot_)net
I presume there might be a special subject? Otherwise, things like *THIS*
message would have triggered such a rule.
The following would match against the BODY looking for a line which starts
with Email (though it isn't case sensitive), and will take the text after
that (minus leading whitespace), and assign it to the $MATCH
variable. This isn't complete, but is the initial framework of the rule:
:0
* !^FROM_DAEMON
* !^X-Loop: youraddr(_at_)yourdomain(_dot_)tld
{
:0B
* ^Email:[ ]*\/[^ ].*
{
# FILTER - add a header so we know about this message
# if it comes back to us.
:0f
| formail -A "X-Loop: youraddr(_at_)yourdomain(_dot_)tld"
# Insert additional rules here (after the X-Loop, before
# the delivery below).
# File a copy of this message in a local mailbox
# (if you don't want to do this, just ensure that the last
# inserted rule inserted above this point DOES NOT have the
# c flag, then omit this rule).
:0
in-subscribe
}
}
What I need to do is the following:
1) Forward the email I receive to another person (I know how to do that)
Add the following at the insertion point above:
# forward to some list admin
:0c
! otherperson(_at_)theirdomain(_dot_)com
This will end up forwarding the message AS IS - it doesn't appear to be
from you (as the From: is still unchanged), though the X-Loop header will
be present (which is good - a bounce or autoreply from this other address
shouldn't trigger a loop).
2) Extract the email address from the email I get and send a pre-composed
email to that person (no clue how to do this)
The MATCH construct (the \/ stuff) in the rule above will obtain the email
address which follows the email address. So, insert the following:
# Tell the user they're being subscribed.
:0c
| ( formail -rt -I "Subject: You're being subcribed to ABC" \
-I "To: $MATCH" ;\
cat $AUTOREPLY/subscribereply.msg ) | $SENDMAIL -t
Obviously, you need to define the $AUTOREPLY path earlier in the script:
AUTOREPLY=$home/.procmailrc/texts
(or something to that effect)
3) And, if I'm lucky, it'd be nice to send an email to a listserv I
maintain (on LetterRip for the Mac) that looks like it's coming from that
person, so I can add them to a mailing list. That's not absolutely
necessary though.
I presume you don't want the body, but sending it to a specific address is
sufficient? Insert the following:
# Forward along a subscription request to the listserv
:0c
| (formail -rtzx -I "From: $MATCH" \
-I "To: yourmailinglist(_at_)domain(_dot_)tld" \
-I "Subject: subscribe $MATCH" ;\
cat $AUTOREPLY/subscribeuser.msg ) | $SENDMAIL -t
I'm no doubt abusing the formail syntax here, but I'm fairly certain this
will work -- it'll ditch the body and most headers in the process of
generating the reply headers (though it'll retain the X-Loop which was set
previously, which you want to keep), then you're replacing most of the
significant ones and appending a static text message to it, and having
sendmail deliver to the address listed in the To: field (which you've
conveniently replaced).
So, what you end up with:
AUTOREPLY=$home/.procmailrc/texts
:0
* !^FROM_DAEMON
* !^X-Loop: youraddr(_at_)yourdomain(_dot_)tld
{
:0B
* ^Email:[ ]*\/[^ ].*
{
# FILTER - add a header so we know about this message
# if it comes back to us.
:0f
| formail -A "X-Loop: youraddr(_at_)yourdomain(_dot_)tld"
# forward to some list admin
:0c
! otherperson(_at_)theirdomain(_dot_)com
# Tell the user they're being subscribed.
:0c
| ( formail -rt -I "Subject: You're being subcribed to ABC" \
-I "To: $MATCH" ;\
cat $AUTOREPLY/subscribereply.msg ) | $SENDMAIL -t
# Forward along a subscription request to the listserv
:0c
| (formail -rtzx -I "From: $MATCH" \
-I "To: yourmailinglist(_at_)domain(_dot_)tld" \
-I "Subject: subscribe $MATCH" ;\
cat $AUTOREPLY/subscribeuser.msg ) | $SENDMAIL -t
# File a copy of this message in a local mailbox
# (if you don't want to do this, just ensure that the last
# inserted rule inserted above this point DOES NOT have the
# c flag, then omit this rule).
:0
in-subscribe
}
}
As per my disclaimer, this is untested and unwarranted. Nevertheless, it
should serve as a starting point for your solution.
---
Sean B. Straw / Professional Software Engineering
Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
Please DO NOT carbon me on list replies. I'll get my copy from the list.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail