Hey all any one suggest me how can i send an email from <textarea> as content to the table users. User table having. * Username * Full Name * Email
Something like this? $get_users = mysql_query("SELECT username, full_name, email FROM users"); //get all users $first = 1; while($user = mysql_fetch_assoc($get_users)) { //loop through all of them if(!$first) { $users .= ", ".$user['username']; }else{ $users = $user['username']; $first = 0; } } $subject = "Some subject"; $message = "Some message"; //<-- e.g. $_POST['textarea_name'] $mail = mail($to, $subject, $message); PHP:
You're very welcome, I'm glad I could help Let me know if you can get it to work or if you have any other questions! Cheers, Webcodez.
i believe you would need the mail function within the while loop in order to sesend the message to each user
Yes, the mail function should be inside the loop. Also, consider sending around 10 emails at a time. Process the remaining later.
Sending more than 500 emails / per hour / per domain is not considered a good practice and thanks there is a high possibility of server ip getting blacklisted as a spam server
1- Page which contain your form (<form><textarea> ....) .... <body> .... <form action="sendmessage.php" method="get" name="msgform" id="msgform"> <p>Subject: <input type="text" name="msg_textfield" id="msg_textfield" /> </p> <p> Message <textarea name="msg_textarea" id="msg_textarea" cols="45" rows="5"></textarea> </p> <p> <input type="submit" name="snd_msg" id="snd_msg" value="Send" /> </p> </form>.... </body> PHP: 2-Page which contain php script to send email (php page ex:sendmessage.php) $get_users = mysql_query("SELECT username, full_name, email FROM users")or die(mysql_error()); $first = 1; while($user = mysql_fetch_assoc($get_users)) { $to = $user['email']; $subject = $_POST['msg_textfield']; $message = $_POST['msg_textarea'];; $mail = mail($to, $subject, $message);} PHP: