View Full Version : anonymous e-mailing with automatic forwarding?

06-09-2004, 11:25 AM
I am making an Asian American community site, where people can email one another directly, without revealing their actual email addresses. Although I know a bit of CGI, C++, Perl, PHP and have created some simple mySQL databases on Linux, I know next to nothing about Sendmail, so to make this work, I barely know how to even begin.

Here's what I'm trying to do:

The part I can do:
1) Users register at the site, and also register their email address, which is stored in mySQL.
2) The site gives each member a randomized forwarding address, with my site as the domain. This is also stored in mySQL.
3) The forwarding addresses of registered members are publicly available to other members.

The part I CAN'T do:
4) Registered UserA emails Registered UserB, using UserB's forwarding address.
5) When the email arrives at my site's mail server, the site identifies it as one of the forwarding addresses (perhaps because the To: line contains my domain name as well as a tell-tale part, like "user" in "user678294@domain.com"
6) The site checks the mysql database to confirm it is a valid forwarding address.
7) if it is, the site alters the To: part of the email to the actual email address behind the forwarding address (i.e. To: user678294@domain.com becomes doug_smith@aol.com.)
8 ) in addition, the site alters the From: part of the email (which carries the sender's actual e-mail address) and changes that to the sender's forwarding address.
9) It then forwards the altered email to its proper destination.

Your advice on how to proceed and where to start would be really, really appreciated! Note that the site will be hosted on Westhost, and my knowledge of Sendmail and Procmail is very weak, although I'm willing to research and study a lot to get this working. I have already searched and searched the Web for advice, but gotten nowhere. I have the O'Reilly Sendmail book and the Red Hat 9 Linux Bible, but they didn't help too much either.

Advice, references would be awesome. If you're really good at what you do, and are willing to write a very comprehensive, easy to use, step by step guide, I might even be willing to pay a small fee or something. I really, really want to learn how to do this. THANK YOU!

06-09-2004, 12:53 PM
If I had to solve this problem on my own, I'd think logically, like I always do, and use this method to approach the problem:

1. Enable the catchall on the account (obviously).
2. Use Procmail to catch the user* mail, as you say, and pipe it ("send" or "forward") the mail to a Perl or PHP script.
3. The Perl/PHP script parses the input, separating the headers, removing and replacing as necessary (with data from your mySQL tables) and uses "built in" methods for sending off the newly formed e-mail.
4. Sendmail doesn't even have to know what has happened.

Of course, as I said I am thinking completely logically: whether this will work in practice is a different matter. Come to think of it, I don't think there is any (other) way to do what you want to - because mySQL is involved, at some point or another a Perl or PHP script needs to be used. If this is the case, you could use PHP's mail() once you have parsed all the headers/body/etc. - and not have to worry about Sendmail configuration or anything at all.

Additional considerations come to mind, thought: the most prominent being the fact that this might be a really inefficient way to do what it is you want to, considering how many resources would be required for this (though you should not have to worry about that), especially if your site turns out to be really popular.

I'd be happy to help you with the Procmail bit, as I am some what of a Procmail enthusiast. I used to be really good with PHP too, but I am rusty - however, I can help you out on that front too. If you choose Perl though, you'll be on your own!

Good luck.

01-10-2006, 10:27 PM
hi FZ,
If possible can you post your info on Procmail and making this work with php.
I kinda have a post out where i want to do something with emails and have it connect to a php script to store the message. you can check my post here: