Send e-mail to a user only

Started on the old forum in November 2009 · view the original in the archive · old links redirect here

14 replies · 831 views · started 17 years ago · 1 min read

6 participants
Mysterio Lead · 630 posts #1

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 "; echo "It will be sent on $user"s email inbox.

";

echo "<form action='?what=sendemailnow' method='post'>"; echo "<input type='hidden' name='user' value='$user'>"; echo "Subject: <input name='subject' maxlength='30' /> "; echo "Message:

<textarea name='message'></textarea>

"; echo "<input type='submit' value='Send'/></form>"; echo "";

}

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. "; 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 = "Send e-mail"; } echo "$mail</br>";


if you dont know how to make it for your site, ask for help here, me or others will help.

mysterio.al - programming is a functional art

nclemale36 Lead · 537 posts #2

i like this but think theres a spamming problem. as ppl will just email ppl other sites very easily instead of using pms that can be auto detected for spam . am i right ??

kei_ki7 Senior · 431 posts #3

im using this, and yahoo did not tell that the mail is spam

Did I help you? You can help me too Your donations will help me finance my studies.

nclemale36 Lead · 537 posts #4

u dont get wot i mean lol .if a users joins to spam ya site so that all your users join there own site. isnt that a way of it goin undetected. like me sending you an email now and asking you to join my site. . .someone could target all your users and no one would no . .

blackhowk Senior · 411 posts #5

if you have 300 emails into database and you want to deliver to all the script will overload the server. the best way to send is to deliver 5-6 emails per min and for this you must reconsider the script. define a new row with this condition.for this see my previous posts about spam message sender. anyway you must put some headers and server signatures to be received as trust email and you must delete hidden input from form;if you have some data to send from formular to other php files insert into session by user. some ppl may use as spam. insert time as trigger.

Mysterio Lead · 630 posts #6

it sends email only to one user, not to all users a time. and yes, blakhowk, must make only for one mail in minute.

mysterio.al - programming is a functional art

blackhowk Senior · 411 posts #7

this is more difficult because we dnt know what is: newsletter?info?tell a friend? first you must define the message as well.second you need to have confirmation of each registered user with terms and AGREE to receive emails. in some country spam terms are hard to manage.

Mysterio Lead · 630 posts #8

blackhowk wrote: this is more difficult because we dnt know what is: newsletter?info?tell a friend? first you must define the message as well.second you need to have confirmation of each registered user with terms and AGREE to receive emails. in some country spam terms are hard to manage.

come on, it was more like an idea... the confirmation can be done very easy

mysterio.al - programming is a functional art

GiLL Senior · 356 posts #10

rather then provide that option to every user only owner or site admin should have this who could send a bulk mail to all users such as news letter/ new updates etc (must sent few users once might add time as blackhowk said) and why you providing this Feature to users ? when you have internal mailbox system or pop up system ? its just option for spammers else if you wana this then include from spam filter tool or file which can filter spam Messages

more things can add such as

send bulk mail only staff members

send bulk mail only banned members

send bulk mail to all users

left wap stuff

Mysterio Lead · 630 posts #11

lol Gill, why you talk like you are obligated to do that in your site? Why not correct anything on it and bring it here?

mysterio.al - programming is a functional art

GiLL Senior · 356 posts #12

Mysterio3 wrote: lol Gill, why you talk like you are obligated to do that in your site? Why not correct anything on it and bring it here?

does it make sense ? do u have any problem what ever i do at my site?and what did i say wrong ? its forum anyone can post and give a suggestion its up to you like or dont like it read my post before write any bloody things

left wap stuff

Mysterio Lead · 630 posts #13

Ok, I edited the script. It just sends one mail / 30 seconds. Create in your database a table called ibwf_mailcare with a field lastmailtime and put there a value (1 for example).

Lol Gill, why you so nervous? Its not I dont like your post, but your mission is just to find mistakes everywhere. Its better to help each-other, than anouncing ourselves like best coders. And one more thing Gill: don't try to irony my posts by profiting I am pro peace.

mysterio.al - programming is a functional art

GiLL Senior · 356 posts #14

i dont care man lol do what ever you like at your site and find mistakes everywhere? is it bad habit ?its also help to improve security and suggest update new things you wrote as i didnt say your code wrong or anything i am not nervous lol and do you like people come at your site and open your users profile online / offline send them their site link to join ? and you will loose all user one day even you will not come to know where gone and who invited your user and seccond i also gave you a suggestion for you to use filter system i dont know what was wrong in my post next time i wont reply in your topic enjoy

left wap stuff

Mysterio Lead · 630 posts #15

GiLL wrote: i dont care man lol do what ever you like at your site and find mistakes everywhere? is it bad habit ?its also help to improve security and suggest update new things you wrote as i didnt say your code wrong or anything i am not nervous lol and do you like people come at your site and open your users profile online / offline send them their site link to join ? and you will loose all user one day even you will not come to know where gone and who invited your user and seccond i also gave you a suggestion for you to use filter system i dont know what was wrong in my post next time i wont reply in your topic enjoy

Come on bro', why should you be so serious? I just wanted to say you that better help somehow than just criticize. Ok, sorry for what I was wrong but no need to fight. I love Coding-Talk and all users here. When I entered here I was at zero. So, I am here not to teach others, but to talk with others. Peace!

mysterio.al - programming is a functional art

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close