1

I'd like to create a procmail recipe or Perl or shell script that will send an auto response to the original sender as well as anybody that was copied (either To: or cc:) on the original email.

Example:

bob@example.com writes an email to john@example.com and paul@example.com (in the To: field). Copies are sent via cc: to rob@example.com and alice@example.com.

I'd like the script to send an auto response to the original sender (bob@example.com) and everybody else that was sent a copy of the email (john@example.com, paul@example.com, rob@example.com and alice@example.com).

Thanks

brian d foy
  • 129,424
  • 31
  • 207
  • 592

2 Answers2

2

You should be able to accomplish this using the this procmail module for Perl 5. You could also just use the procmail configuration files to do this as well.

Here's an example of our procmail configuration sending e-mails "through" a perl script.

:0fw
* < 500000
| /etc/smrsh/decode_subject.pl

I hope that helps get ya started.

J.J.
  • 4,856
  • 1
  • 24
  • 29
2
FROM=`formail -rtzxTo:`
CC=`formail -zxTo: -zxCc: | tr '\n' ,`

:0c
| ( echo To: "$FROM"; echo Cc: "$CC"; echo Subject: auto-reply; \
    echo; echo Please ignore. ) \
  | $SENDMAIL -oi -t

A well-formed auto-reply should set some additional headers etc; but this should hopefully be enough to get you started. See also http://porkmail.org/era/mail/autoresponder-faq.html

Depending on you flavor of tr you might need to encode the newline differently; not all implementations of tr understand the '\n' format. Try with '\012' or a literal newline in single quotes if you cannot get this to work.

slm
  • 15,396
  • 12
  • 109
  • 124
tripleee
  • 175,061
  • 34
  • 275
  • 318