I'm trying to set up an auto-forwarding system, in which the following happens:
a) user A and user B have actual email addresses A and B and forwarding addresses C and D. This info is stored in the mySQL database of my site.
b) users A and B know each others forwarding addresses through the site, but no one knows anyone's actual email address.
c) user A, from his actual email account, sends a message to user B's forwarding address.
d) site's mail server receives the email. a program alters the email's header line so that the recipient address is changed to user B's actual email address B, and the sender's address is changed to user A's forwarding email address C. Anonymity is therefore preserved.
e) changed email is now put in the mailing queue and sent off.
I'm a linux beginner, and have just managed to make a test server which successfully receives and sends email from the root account. Using advice from other sites, I've done the following:
a. changed /etc/mail/virtusertable and added the following line:
admin@mydomain.com root
@mydomain.com remailer-alias
b. changed /etc/aliases and added the following line:
remailer-alias: |remailer
The idea is all non
admin@mydomain.com emails should be piped into the remailer program. The remailer program should reedit the message and place it in the queue.
The problem is, I'm not sure how to write the remailer program or where to place it. I have written only extremely basic shell scripts or Perl programs, and in particular have not written a program that processed piped information, having used pipes only on the command line. I have tried to make remailer programs just to test the above functionality, for example:
#! /usr/bin/perl -w
# test remailer program in perl
print "hello!\n";
or using a shell script:
#! /usr/bin/sh
# test remailer program, shell script
echo "hello"
I changed the /etc/aliases line to:
remailer-alias: |/etc/mail/remailer
I then placed the remailer file into /etc/mail, chmod-ed it a+rx, and send myself an external email. The email either was bounced or was eaten up. I was hoping that a "hello" would appear to indicate the program was triggered when an email arrived.
My main question is: how do I go about writing the remailer program? Can I write it in Perl, or must I do it in a different language? Do I have to change config files somewhere to make this work? What is a good resource, either online or a book, that would help me become an expert in writing the kind of program that I want, particularly a program that can processed piped in information?
I think if I could get the email to trigger, say, a Perl program, I could probably figure out much of the rest. Its the initial triggering in and of itself that causing me a lot of problems.
Lastly, I do wonder: is this system robust enough to handle, for example, 100-500 forwarded emails a day?
Thanks so much for your help!