Pick username/ password and send auto mail

Discussion in 'MySQL' started by rajivv, Mar 2, 2010.

  1. #1
    HI,

    I had run into problems with my site and site was down for 4 months , now have added new features etc.
    Have to send a mail to all users about new features, have around 7500
    How do I send a mail which automatically picks up the User Dislay name
    So the mail reads 'Dear ( User display name) '
    Also in the same mail want to remind the user of his username and password.
    ' You username is (username) and password is (password)

    How to do this automatically for the 7500 users ????
    Please help

    Regards
    Rajiv
     
    rajivv, Mar 2, 2010 IP
  2. rayqsl

    rayqsl Active Member

    Messages:
    91
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    53
    #2
    It all depends on the programming language you're using. What is it.

    BTW. don't email passwords. Emails are not secure.
     
    rayqsl, Mar 2, 2010 IP
  3. rajivv

    rajivv Peon

    Messages:
    335
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    site is coded in PHP

     
    rajivv, Mar 2, 2010 IP
  4. jimmy4feb

    jimmy4feb Peon

    Messages:
    56
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hello,

    Following is the solution of your problem, I am assuming that you are getting userName, password, name, emailAddress from database table userTable. Following is an example:

    
    userTable
    userName      password       name             emailAddress
    user1              pass1           name1           email1@domain.com
    user2              pass2           name2           email2@domain.com
    user3              pass3           name3           email3@domain.com
    
    Code (markup):
    Following is PHP code to send emails using this table
    
    <?php
     $conn = mysql_connect('www.yourDomain.com', 'username', 'password') or die("ERROR: Unable to connect to sever");	
     mysql_select_db('yourDatabaseName', $conn) or die("ERROR: Unable to find database");
     $sql = "SELECT userName, password, name, emailAddress FROM userTable"; 
     $result = mysql_query($sql) or die("Table does not Exist");
     if(mysql_num_rows($result) > 0)
     {
      while($row = mysql_fetch_array($result))
       {
        $to = $row['emailAddress'];
        $subject = "Subject of your email";
        $msg = "Dear".$row['name'].",<br>User Name: ".$row['userName']."<br>Password: ".$row['password']."<br>You can add your message here & update this message according to your requirement";
        $headers = "From: webmaster@example.com" . "\r\n" ."CC: somebodyelse@example.com";
        mail($to,$subject,$msg,$headers);
        }
      }
    ?> 
    
    PHP:
    This script will send email to all the users which are existing in this table.
    If you any any question, then ask..... I will try to help

    Thanks,
    Jimmy
     
    jimmy4feb, Mar 3, 2010 IP