Here is a simple script that can send e-mail to registered users in your site (for example to one of your friends) if they have email, of course.
I called it mail-to-friend.php but you can change it and table structures to match with your lavalair/wapdesire site, for example.
-----
$what = $GET_['what'];
if ($what == "") {
$user = $_GET['user'];
echo "Send email to $receiver<br/>";
echo "It will be sent on $user\"s email inbox.<br/><br/>";
echo "<form action='?what=sendemailnow' method='post'>";
echo "<input type='hidden' name='user' value='$user'>";
echo "Subject:<br/><input name='subject' maxlength='30' /><br/>";
echo "Message:<br/><textarea name='message'></textarea><br/>";
echo "<input type='submit' value='Send'/></form>";
echo "</center>";
}
else if($what=="sendemailnow"){
$time = time();
$whenlastmail = mysql_fetch_array(mysql_query("SELECT lastmailtime FROM ibwf_mailcare"));
$checkit = $whenlastmail[0] + 30;
if ($time <= $checkit)
{
echo "Server is too busy. Please try again.<br/>";
exit();
}
mysql_query("UPDATE ibwf_mailcare SET lastmailtime='".$time."'");
$user = $_POST['user'];
$sender = myname($session);
$subject = $_POST['subject'];
$message = $_POST['message'];
$title = $_POST['title'];
$email = mysql_fetch_array(mysql_query("SELECT email FROM members WHERE user='".$user."' "));
$msg = "$message";
$msg .= "\n\n";
$msg .= "This e-mail has been sent by $sender (member of Virtual City).\n";
$msg .= "To answer, login to Virtual City by using your name and password.\n\n";
$msg .= "www.vcity.us.to\n";
$subject = "".$title."";
$headers = "From: noreply@vcity.us.to";
$senditnow = mail($email[0], $subject, $msg, $headers );
if ($senditnow) { echo "Message sent to $receiver."; }
else { echo "Message could not be sent to $receiver."; }
}
-----
and this one is to add in the users profile:
$email = mysql_fetch_array(mysql_query("SELECT email FROM members WHERE user='".$user."' "));
if ($email[0] == "")
{
$mail = "Send e-mail";
}
else
{
$mail = "<a href='mail-to-friend.php?session=$session&user=$user'>Send e-mail</a>";
}
echo "$mail</br>";
-----
if you dont know how to make it for your site, ask for help here, me or others will help.
I called it mail-to-friend.php but you can change it and table structures to match with your lavalair/wapdesire site, for example.
-----
$what = $GET_['what'];
if ($what == "") {
$user = $_GET['user'];
echo "Send email to $receiver<br/>";
echo "It will be sent on $user\"s email inbox.<br/><br/>";
echo "<form action='?what=sendemailnow' method='post'>";
echo "<input type='hidden' name='user' value='$user'>";
echo "Subject:<br/><input name='subject' maxlength='30' /><br/>";
echo "Message:<br/><textarea name='message'></textarea><br/>";
echo "<input type='submit' value='Send'/></form>";
echo "</center>";
}
else if($what=="sendemailnow"){
$time = time();
$whenlastmail = mysql_fetch_array(mysql_query("SELECT lastmailtime FROM ibwf_mailcare"));
$checkit = $whenlastmail[0] + 30;
if ($time <= $checkit)
{
echo "Server is too busy. Please try again.<br/>";
exit();
}
mysql_query("UPDATE ibwf_mailcare SET lastmailtime='".$time."'");
$user = $_POST['user'];
$sender = myname($session);
$subject = $_POST['subject'];
$message = $_POST['message'];
$title = $_POST['title'];
$email = mysql_fetch_array(mysql_query("SELECT email FROM members WHERE user='".$user."' "));
$msg = "$message";
$msg .= "\n\n";
$msg .= "This e-mail has been sent by $sender (member of Virtual City).\n";
$msg .= "To answer, login to Virtual City by using your name and password.\n\n";
$msg .= "www.vcity.us.to\n";
$subject = "".$title."";
$headers = "From: noreply@vcity.us.to";
$senditnow = mail($email[0], $subject, $msg, $headers );
if ($senditnow) { echo "Message sent to $receiver."; }
else { echo "Message could not be sent to $receiver."; }
}
-----
and this one is to add in the users profile:
$email = mysql_fetch_array(mysql_query("SELECT email FROM members WHERE user='".$user."' "));
if ($email[0] == "")
{
$mail = "Send e-mail";
}
else
{
$mail = "<a href='mail-to-friend.php?session=$session&user=$user'>Send e-mail</a>";
}
echo "$mail</br>";
-----
if you dont know how to make it for your site, ask for help here, me or others will help.
Comment