Jump to content

[SOLVED] Using PHP to create temporary emails, and forward to the real addresses


Iki

Recommended Posts

Hi all,

 

Here's the situation: I run a site where people who have online roleplaying games can recruit new players. The entire site is php, and completely automated.

 

A person goes there and submits their announcement. The announcement is placed into the mysql database along with a randomly generated alphanumerical code, and then a sequential numerical code. The site then sends them an email with the contents of their announcement in it, along with the numerical code. They bring that code back to the site, input it, and approve or delete their announcement. It remains on the site for 10 days, then every night a script runs that deletes anything over 10 days old.

 

The problem with this is, everyone's emails - which have been verified as being good because they had to retrieve that key code out of it - are right out there on the web for 10 days for any scumbag to scrape up. 

 

Here's what I'm thinking, but I'm not sure quite how to accomplish this.

 

When the announcements appear, I'd like their email addresses to show up as "[email protected]"  so it'd be the assigned alphanumeric in the database, plus my site's domain, not theirs. Then I'll make a "catch-all" address in cPanel that points to a php script. I'll have that script search the database for that particular alphanumeric, then forward the contents of the email to my user's REAL email address.

 

Sounds simple enough... but I have no idea where to start to build such a beast. Any ideas?

 

 

u r already generating an alphanumeric key when the user posts the announcement.. you can use the same.

 

in the PHP script u will link with cath-all do the following:

 

sudo code

 

//connect to datbase

//Use the TO email field to extract aplhanumeric key...us can use explode() for this..

//fire query to fetch user email address from datbase using this alphanumeric key.

//send mail.

 

is this what r u trying to do? if not please excuse me...

Thanks for the reply! I've been thinking about it since I posted that, and what I'm trying to do is what craiglist.org does. When you put up an ad, you get a fake email address that forwards to your own so your real email isn't out there for spammers to steal.

 

What I need is a php code snippet that will check an email box and grab the contents - To, From, Subject, and Body. If I can grab that, I think I can make it do the rest of what I need (or you'll see me in here again.  ;D )  Once I have that stuff, I think I can figure out how to do the database compare and grab what I need from there to shove it all into another email going to the desired recipient.

 

But it's checking the mailbox that's the big hurdle right now. If anyone has any ideas, or can point me in the direction of some code I can study, that'd be great.

 

Iki

  • 4 weeks later...

For anyone who's interested, this will check a mailbox and spew out the contents in array form.

 

<?php

echo "<pre>";
echo "opening box \r\n<br />\r\n";
$mbox = imap_open("{your.mail.server.path.to/imap}INBOX", "username", "password");

if (!$mbox) {
   print_r(imap_errors());
   echo "<br>";
}

// Fetch an overview for all messages in INBOX

echo "box is open \r\n<br />\r\n";

$msgcount = @imap_num_msg($mbox);
echo ("Total messages: " . $msgcount . "<br />");
$i = 0;
while ($i < $msgcount) {
        $msgno = $i + 1;
echo "message number " . $msgno . " \r\n<br />\r\n";
        $header = imap_headerinfo($mbox, $msgno);
        print_r($header);
        echo "\n\n";
$msgbody = imap_body($mbox, $msgno);
print_r($msgbody);
        echo "\n\n";
        $i++;
}
echo "</pre>";
imap_close($mbox);
?>

 

Also found a nice tutorial about imap here.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.