PDA

View Full Version : Private Email Hack


05-21-2000, 06:55 PM
Send an email from one registered user to another with this:

// ############################### start email form ###############################

if ($action=="mailform") {

echo "<form action=\"member.php\" method=post>\n";
echo "<input type=hidden name=action value=sendmail>\n";
echo "To:<br><input name=username value=\"$username\"><br>\n";
echo "From:<br><input name=from value=\"$bbusername\"><br>\n";
echo "Subject:<br><input name=subject value=\"From @forums Member\"><br>\n";
echo "Message:<br><textarea rows=10 cols=40 name=message></textarea><br>\n";
echo "<input type=submit>\n";
echo "</form>\n";

}

// ############################### start send email ###############################

if ($action=="sendmail") {

$body=urldecode($message);
$title=urldecode($subject);
$username=urldecode($username);
$fromusername=urldecode($from);

$user=$DB_site->query_first("SELECT userid FROM user WHERE username='".addslashes($username)."'");
$userid=$user[userid];
$userinfo=$DB_site->query_first("SELECT username,email FROM user WHERE userid=$userid");
$useremail=$userinfo[email];
$username=$userinfo[username];

$fromuser=$DB_site->query_first("SELECT userid FROM user WHERE username='".addslashes($fromusername)."'");
$fromuserid=$fromuser[userid];
$fromuserinfo=$DB_site->query_first("SELECT username,email FROM user WHERE userid=$fromuserid");
$fromuseremail=$fromuserinfo[email];
$fromusername=$fromuserinfo[username];

$fromuser="\"$fromusername\" <$fromuseremail>";

mail("\"$username\" <$useremail>", $title, $body, "From: $fromuser");

echo "Mail Sent!\n";

}

Just put this snippit into "member.php" and update the "postbit_useremail" so that the HREF points to "member.php?action=mailform&username=$username"

[Edited by Lord Raven on 05-22-2000 at 01:58 AM]

05-21-2000, 07:03 PM
is replace the mailto: link in the postbit with an anonymous form that doesn't reveal the users' e-mail address to whoever is sending the mail.

It will also help protect against people will take the time to harvest your users' e-mail addy for spamming, like Chris from extremeforums did us on the UBB.

See it in action at: @forums Beta Forum (http://216.247.232.129/showthread.php?threadid=6437)

Note: You hafta sign up for this to work properly and put your name in the From slot :)

05-22-2000, 01:33 PM
This is a great hack! This really should be an option built into the board. :)

05-22-2000, 02:38 PM
John's gonna do that:)

I'll prolly templatize it tonight (or screw it up trying) and send the template code and php file to him for inclusion in the 1.1.2 release.

If I can't get it, I'm sure John will (or some other enterprizing hacker)

Tonight's project is a SUPER basic My Topics list. Nothing more than a search, really, but it should suffice until we get an altertable routine to do the real thing.

05-22-2000, 06:50 PM
Martin:

If you really think about this it really is the private messages hack that people have been wanting only it sends the private message via email instead of to the board.

Now what would be cool is if you could read your email with this via an smtp or pop call with the member putting in their username and password to their email account and the script could tell them they have private mailing waiting while they are surfing your forum.

Cool hack BTW.

Parker

05-22-2000, 07:07 PM
The private message hack would require four new tables in the forum database to store from, to, subject and message. I think it would actually be easier to implement here than with UBB.

The hack was by Lord Raven, one of my members and a friend. My contribution was pretty limited.

05-22-2000, 09:17 PM
If anyone is interested, here's a version of the hack that calls on the user's mail client to do the sending :D


<?php

require("global.php");

$username=$QUERY_STRING;

$username=urldecode($username);
$user=$DB_site->query_first("SELECT userid FROM user WHERE username='".addslashes($username)."'");
$userid=$user[userid];

// display user info

$userinfo=$DB_site->query_first("SELECT email FROM user WHERE userid = $userid");
$mememail=$userinfo[email];
$mailto="mailto:$mememail";
header("Location:$mailto");

?>


Just put that into a file (e.g membermail.php) and call on it in the templates using the form membermail.php?$username

Hope that's useful to anyone...

05-23-2000, 04:37 PM
Originally posted by redranger
If anyone is interested, here's a version of the hack that calls on the user's mail client to do the sending :D



What about people who use Hotmail or some other web based email client?

Besides that, it would show the user the email address. The sole reason for creating this hack was to conciel(sp?) the user's email address.

[Edited by Lord Raven on 05-23-2000 at 11:38 PM]