|
 |
|
 |
03-04-2005, 07:14 AM
|
#1 (permalink)
|
|
If I Only Had a Brain
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
|
Craigslist Anonymous Email Relay with PHP & MySQL?
I have a guestbook application that uses a webform to enter into a MySQL database.
The entries from that database are displayed on another page, sort of like a guest book or bulletin board.
What I would like to do is instead of having their real email listed, I would like to assign them a temporary email that will forward to their real address, so that the initial responder does not see the real email address, i.e. my email would be changed to tab123456@domainname.com and when anyone sends email to that address, it is looked up in the db and then email is sent to the correct address. Does that make any sense?
This is exactly what http://www.craigslist.org does, and I have been looking all over for a script or an application or anything that will do that and I have had no luck. The closest I have found is a form on a website that will send email aa hidden email address based on an id.
Anyhelp would be much appreciated!
|
|
|
03-04-2005, 08:11 AM
|
#2 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,444
|
seems like more of a job for a mail server rather than php/mysql. i don't know how php/mysql would receive the initial email.
__________________
Mike
|
|
|
03-04-2005, 08:27 AM
|
#3 (permalink)
|
|
If I Only Had a Brain
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
|
Hmm, yes I was wondering if that would be the case, if so, then I maybe able to do this as an alternative, but I am not sure how:
From the website, a visitor could click on the email link which will bring up a form that does not contain the actual email, but the id, and then forwards it to this person. I know this can be done, becasue I have seen a similar application, but it used a flat text file instead of a database, and I need it to pull from the database. Here was the example, I just need help in modifying it:
http://www.theadultbroker.com/php_mailscript/index.php
|
|
|
03-04-2005, 08:35 AM
|
#4 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,444
|
yes, now that would completely work with a web form. do you need help to implement this? the logic would go something like this: ( haven't tested the code )
PHP Code:
<?
if($_POST['submit']){
$result = mysql_query("select email from users where id=".$_POST['id']);
if($row = mysql_fetch_array($result)){
mail($row[0], $_POST['subject'], $_POST['message'], "From: ".$_POST['from']);
echo "Email Sent";
}else{
echo "Email Failed";
}
}else{
?>
<form method=post action=<?=$_SERVER['PHP_SELF']?>>
<input type=hidden name=id value=552>
From: <input type=text name=from><br>
Subject:<input type=text name=subject><br>
Message:<textarea name=message></textarea><br>
<input type=submit name=submit value=send>
</form>
<?
}
?>
__________________
Mike
|
|
|
03-04-2005, 08:39 AM
|
#5 (permalink)
|
|
If I Only Had a Brain
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
|
Thank you thank you soo much! I will try that and see if I can make it work!
|
|
|
03-04-2005, 03:14 PM
|
#6 (permalink)
|
|
If I Only Had a Brain
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
|
Ahhhhhhhhhhhhhhhhhhhh I am going to pullout all of my hair! Can you help implement this, how much would you charge?
|
|
|
03-04-2005, 03:41 PM
|
#7 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,444
|
eleventy-billion dollars  .. what is wrong? show me what you got, errors, and tell me what it is or isn't doing.
__________________
Mike
|
|
|
03-04-2005, 03:57 PM
|
#8 (permalink)
|
|
If I Only Had a Brain
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
|
I have a page that retrieves a single record from the MySQL database based on a URL string query, assigns a variable to each field, and displays the results of each variable and this works:
PHP Code:
<?php
include 'config.php';
include 'opendb.php';
$query = "SELECT id, name, email, message FROM guestbook WHERE id = '$searchid'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$id = ("{$row['id']}");
$name = ("{$row['name']}");
$email = ("{$row['email']}");
$message = ("{$row['message']}");
}
echo "$id<BR>";
echo "$name<BR>";
echo "$message<BR>";
echo "$email<BR>";
include 'closedb.php';
?>
BUT... if I add anything else to it, like the part of a form, it doesn't retain the variable information....only what was in the original querystring....
<?php
include 'config.php';
include 'opendb.php';
$query = "SELECT id, name, email, message FROM guestbook WHERE id = '$searchid'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$id = ("{$row['id']}");
$name = ("{$row['name']}");
$email = ("{$row['email']}");
$message = ("{$row['message']}");
print("<h2>Send an e-mail to ");
echo ("$name</h2>");
echo ("<form name=\"form1\" method=\"POST\" action=\"contactmesent_old.php\">");
echo ("<input type=\"hidden\" name=\"searchid\" value=\"$searchid");
blah blah blah more form info.....
include 'closedb.php';
}
?>
and contactmesent_old.php would contain the mail command, along with the information from this form, which I haven't even gotten to, but the idea is to have an email submit form where the email address is hidden from the user.
Am doing this totally wrong or what? Any help or pointing in the right direction would be sooo much appreciated!
|
|
|
03-04-2005, 04:13 PM
|
#9 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,444
|
maybe this ..
PHP Code:
<?php
include 'config.php';
include 'opendb.php';
// if the form has not been posted, print the form
if(!$_POST){
$query = "SELECT id, name, email, message FROM guestbook WHERE id = '".$searchid."'";
$result = mysql_query($query);
// since we're only getting 1 row, we can use 'if' instead of 'while'
if($row = mysql_fetch_assoc($result))
{
$id =$row['id'];
$name = $row['name'];
$email = $row['email'];
$message = $row['message'];
echo "<h2>Send an e-mail to ".$name."</h2>
<form name=\"form1\" method=\"POST\" action=\"contactmesent_old.php\">
<input type=\"hidden\" name=\"searchid\" value=\"".$searchid."\">
Your Email: <input type=\"text\" name=\"from\"><br>
Subject: <input type=\"text\" name=\"subject\"><br>
Message: <textarea name=\"message\"></textarea><input type=\"submit\" value=\"send\">
</form>";
}else{
echo "error: id not found";
}
}else{
// send email and say thank you
$result = mysql_query("SELECT id, name, email, message FROM guestbook WHERE id = '".$_POST['searchid']."'");
if($row = mysql_fetch_assoc($result)){
mail($row['email'], $_POST['subject'], $_POST['message'], "From: ".$_POST['from']);
echo "Thank You, Your email as been sent";
}else{
echo "Error: Invlid User ID";
}
}
mysql_close();
?>
__________________
Mike
|
|
|
03-04-2005, 04:26 PM
|
#10 (permalink)
|
|
If I Only Had a Brain
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
|
OMG! I LOVE YOU! I just changed one thing, to post to itself and it worked! OMG YOU ARE A GENIUS! What can I do to repay you?!?!?!
xoxoxoxoxoxoxo
|
|
|
03-04-2005, 07:26 PM
|
#11 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,444
|
you're not too far, .. how about leave an ice cold six pack of heineken on my porch for when i get home from work monday.  .. j/k, .. just visit more or tell people about our community.
i'm glad it works, happy to help.
__________________
Mike
|
|
|
03-05-2005, 08:10 AM
|
#12 (permalink)
|
|
If I Only Had a Brain
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
|
You bet! This is my new favorite second home!
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 02:22 PM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|