Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2013
    Posts
    1

    Question Unanswered: Send mail to ALL not only 1, Pls help me

    hello, my name is Ezra and im new here, and novice in pvp and sql, for first sorry for my bad English.
    I have an website in php with SQL Server database(GAME SERVER) and I create an mail function in that game, and player send mail(message) to specific people, my function in include.php is this:
    PHP Code:
    function mumail(){
     if ((isset(
    $_SESSION['pass'])) && (isset($_SESSION['user']))); {
     
    $login secure($_SESSION['user']);
     
    $account secure($_POST['account']);
     
    $from_user secure($_POST['from_user']);
     
    $to_user secure($_POST['to_user']);
     
    $msg_user secure($_POST['msg_user']);
     
    $ipdb $_SERVER['REMOTE_ADDR']; 
     
    $executetime date('Y-m-d H:i:s');
     
    check_inject();


     
    $isuser mssql_query("SELECT Name FROM MuOnline.dbo.T_FriendMain WHERE Name = '$to_user'"); 
     
    $issql mssql_num_rows($isuser);

     if (
    $issql == "0"){
     echo 
    "<span class='alert'>No Character with that name was found!</span>";
     echo 
    "<span class='alert'>Message was not sent!</span>";
     }else{

     
    $presql mssql_query("SELECT GUID FROM MuOnline.dbo.T_FriendMain WHERE Name='$to_user'"); 
     
    $line mssql_fetch_row($presql);

     
    $aftsql mssql_query("SELECT MemoCount,MemoTotal FROM MuOnline.dbo.T_FriendMain WHERE Name='$to_user'"); 
     
    $aftres mssql_fetch_row($aftsql); 

     
    $mailID $aftres[0] + 1;
     if (
    $mailTOT == "1"){
     
    $mailTOT $aftres[1];
     }
     else{
     
    $mailTOT $aftres[1] + 1;
     }
     
    $date date("m/d/y");
     
    $time date("H:i:s"); 

     
    $sql mssql_query("INSERT INTO MuOnline.dbo.T_FriendMail (MemoIndex, GUID, FriendName, wDate, Subject, bRead, Memo, Photo, Dir, Act) VALUES ('$mailID','$line[0]','$from_user','$date $time','Website Msg','0',CAST('$msg_user' AS VARBINARY),CAST('9999999999999999999' AS VARBINARY),'143','8')");
     
    $sql2 mssql_query("UPDATE MuOnline.dbo.T_FriendMain set MemoCount = '$mailID', MemoTotal = '$mailTOT' WHERE Name = '$to_user'");
     echo 
    "<span class='succes'>Message was sent!</span>";
     }
     }
     } 
    and FORM for this function is this:
    PHP Code:
    <h1>Mu Mail System</h1>
     <
    table>
     <
    thead>
     <
    tr>
     <
    td>From</td>
     <
    td>To</td>
     </
    tr>
     </
    thead>
     <
    tbody>
     <
    form action="" method="post" onsubmit="return checkform(this);">
     <
    tr align=center>
     <
    td>
     <
    input type="text" name="from_user" maxlength="10" value="">
     </
    td>
     <
    td>
     <
    input type="text" name="to_user" maxlength="10" value="" >
     </
    td>
     </
    tr>
     <
    thead>
     <
    tr>
     <
    td colspan=2>
     
    Message
     
    </td>
     </
    tr>
     </
    thead>
     <
    tr align=center>
     <
    td colspan=2>
     <
    input type="text" rows="4" cols="50" name="msg_user" maxlength="1000" value=""/>
     </
    td>
     </
    tr>
     <
    tr align=center>
     <
    td colspan=2>
     <
    input type="submit" name="mumail" value="Send Mail" class="button">
     </
    td>
     </
    tr>
     </
    form>
     <
    tbody>
     </
    table
    this is for normal user and work code is good don't have problem with him but now I want to send MASS MAIL to all user and I try to create function for send same mail to all user from my database, who can help me with little IDEEA how to start to code this? because I block when I see to row in database for for one USER (GUID and Name)
    THX, and sorry again for my bad English.

  2. #2
    Join Date
    Jan 2014
    Posts
    4
    Here is some copy paste of code I use to send bulk info to users in one of my deactivated sites..

    PHP Code:

    //selects everything from my users table (you could have it just select the email addresses)
    $SQL_Select_Users "SELECT * FROM users";
    $Result_Select_Users mysql_query($SQL_Select_Users );

    //if it cannot select the table error out.
    if(!result)
        {
            echo
    'Could not access the database.. <br> Error: mail_bulk_admin - SQL !Result_Select_Users- Fail';
        }
        
    else
        {
            
    //make sure the server is in post mode
        
    if($_SERVER['REQUEST_METHOD'] != 'POST')
                 {
                 
    //Note* Form Action must be the name of the php file that contains this script(IE the file you are working on)
                 
    echo'<form method="post" action="mail_bulk_admin.php">
                 Subject: <input type="text" name="Subject" size="15"><br>
                         Message:<br> 
                        <textarea name="message" rows="15" cols="40"></textarea><br> 
                        <input type="submit"> 
                        </form>'
    ;
             }
            
    //if server is not in post mode
        
    else
            {
                
    //generate the from, make sure to put your email in here for from
                
    $from "Your_Email_Here@none.com";  
                
    $subject =  stripslashes(ereg_replace('"','"',$_POST['Subject']));  
            
    $message =  stripslashes(ereg_replace('"','"',$_POST['message']));
            
                
    $headers "From: $from";
            
    $headers  .= 'MIME-Version: 1.0' "\r\n";
                
    $headers  .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";

            
                echo
    '<table>';

                
    //get each user one at a time, send a email, and report if it was a success or not
            
    while($row mysql_fetch_assoc($result))
                     {
                     
    $email $row['user_email'] ;        
                 
    $sent mail($email$subject$message$headers) ;    
                     if(
    $sent
                         {
                 echo
    '<tr>
                    <td>Your mail was sent successfully to: ' 
    .$email'</td>
                        </tr>'

                  }
                    else 
                         {
                  echo 
    '<tr>
                              <td>We encountered an error sending your mail to: ' 
    .$email.'</td>
                      </tr>'

                  }
             }
        echo
    'Finished Sending Mail';
            }
        } 

  3. #3
    Join Date
    Feb 2014
    Posts
    1
    I think that the logic will be same as you do for the deactivated sites. You will have to add a connection between the database and fetch the users from the database.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •