Page 1 of 1

E-mail forwarding in PHP?

Posted: Wed Aug 14, 2002 4:29 pm
by newtophp
Oh good and merciful PHP gurus, please indulge this PHP newbie's ignorance. 'Tis my first post, and you wouldn't want to hurt my feelings, would you?

I've searched the forums, I've searched the mighty Google, I've been to yonder and yore, and I've read books mighty and bore, but still can't find anything close that can answer my dilemma: "Can e-mail forwarding be done in PHP?"

You see, good and merciful PHP gurus, I've decided that the only way I can become like any of you is if I get my hands dirty and build my own site from scratch using PHP and MySQL. My first, only and current PHP project is a classified ads site. Most everything is going great so far, except for my e-mail problem.

What I'm doing right now is this:
If an ad poster places an ad on my site, I hide the person's e-mail address and replaces it with an auto-generated "fake" e-mail address instead. So if "john_doe@yahotmaol.com" places an ad, people reading his ad won't see "Send an e-mail to john_doe@yahotmaol.com", instead, if his ad is ad # 200, people will see something like:"Send an e-mail to ad200@mysite.com."

And therein lies my problem. "ad200@mysite.com" is not a real e-mail account on my site, so I know that messages addressed to it will end up in "catchall@mysite.com." From there, how do I relay John Doe's messages to his real e-mail address?

I've seen sites that have this feature, I just can't for the life of me, figure out how to start implementing this on my site.

Can anyone point me in the right direction please? Just a general "#1 Do this; #2 Do that; #3 Do this next; #4 You're done" kind of thing.

"Free beer", although appreciated, is not necessary, just some guidance from the good and merciful PHP gurus lurking around these forums.

If this cannot be done in PHP and I'm therefore posting in the wrong forum, please, please, please my apologies. But if there's some PHP thingy that can do the job, then thank you so much in advance for whatever bit of enlightenment will be thrown my way.

Posted: Wed Aug 14, 2002 4:34 pm
by jason
Even easier would be to eliminate email all together in this aspect.

If I wanted to reply to an ad, I would click a reply button, and then enter my reply, like an email, or like these forums.

Then, the message is stored in the database, and an email is sent to the owner of the ad telling the person they got a message from someone.

Not only is this much easier, but more intuitive, and gets people back to your site. You also have to consider what if I am not on my computer, I can't email someone. So giving them a web based form to do it is much nicer.

Posted: Wed Aug 14, 2002 4:58 pm
by newtophp
Thank you guru Jason!

That's exactly how I wanted to do it, because I know how to implement it in PHP. But -- my webhost frowned upon the idea. Being on a shared hosting env, they said that if an ad gets hundreds/thousands of replies, then an e-mail form can potentially bog down the server, to the detriment of other clients on the same machine. So they said better let anyone who wishes to reply to an ad do so using their own e-mail accounts.

Hence my posting here. But thank you for the insights. If I have no other option, then I'll just probably do the e-mail form thing when my webhost is not looking, hehehe ...

Posted: Thu Aug 15, 2002 8:02 am
by jason
Okay, your hosting provider doesn't know the first thing about PHP then, nor do they understand emails.

A couple rules we can live by:

1. No one ad is going to recieve the thousands of emails the claim. If it does, then you obviously are making money and can get your own server.

2. Email forwarding as you suggest would be more intensive. Email forwarding would not only require retrieving and storing the email, but also then sending the email out. With PHP, you just send an email out.

3. It's your hosts responsibility to clearly define the terms and conditions of your server use. Do you have limited processor use, or did they even bother covering that?

4. As long as your not breaking and of the Terms and Agreements, do it the way you want to. It's not your fault if the host packs their servers full of more than they can handle.

5. And finally, if you are looking for a good host, check out the banners at the top of the page, they are good people and I highly recommend them. :D

Posted: Thu Aug 15, 2002 9:16 am
by newtophp
Thank you once again.

You have strengthened my resolve. I will now do the right thing and just do it using an e-mail form.