SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Location
    California, US
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    send new passwords to all users via email

    I upgraded my system and in doing so am using a new algorithm for password encryptions.

    Does anyone foresee a problem with me running a mail script that simply loops through every user in my database and sends them an email with their new password? There are roughly 6,000 users.

    My first thought is I can loop through but I should set up some sort of interval between each send, something like "send email, wait 5 seconds, send next emails, wait 5 seconds". I don't want to run into a problem with my system sending thousands of emails within a few seconds and raise the possibility that some users might not receive their new password email.

    Just to clarify, the previous system was built through a third party and I have no way of decrypting their passwords encryptions used on for the users.

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah you dont want to send too many emails at once.

    take a look at swiftmailer, its a mailing library that has a plugin designed for this. it connects right to smtp and sends multiple emails which is lighter on the server than the mail() function being called for each email.

    something you should consider though. not all of your users may get the email(maybe it gets sent to thier junk folder).
    maybe they dont check thier email often.
    maybe they ignore the email since it was unsolicited or they think its a phising attack to steal thier password.
    maybe they dont use that email address anymore as they created it just to register for your website.
    and many more possibilities.

    to minimize how many users you may lose in this process, you might want to consider allowing both passwords to still be used until the next log in since the email was sent. create a table and once they log in, make a record to signify that the old password may no longer be used for this user. provide a message upon logging in to inform them of this change, that way you are positive this user has received your message.

  3. #3
    SitePoint Addict
    Join Date
    Mar 2005
    Location
    California, US
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by clamcrusher
    to minimize how many users you may lose in this process, you might want to consider allowing both passwords to still be used until the next log in since the email was sent. create a table and once they log in, make a record to signify that the old password may no longer be used for this user. provide a message upon logging in to inform them of this change, that way you are positive this user has received your message.
    I would love to do that but I do not know the encryption that was used to encrypt the passwords, so I cannot decrypt. This site was created about 3 years ago by some small company that doesn't exist anymore so there is no way for me to get it.

    I did create a "recover my password" form that is obvious on the login page and in the error message upon wrong password entry it directs them to use this form which will email them their new password.

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so currently nobody can log in?

    if they can log in, they can still use the old password.

    and btw- generally its a good thing that you cannot decrypt the password. its safer. thats why its so common to not store a users password, but instead to store an md5/sha1 hash of it using a salt.

  5. #5
    SitePoint Addict
    Join Date
    Mar 2005
    Location
    California, US
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Currently people can because the site is still in the old framework which is hosted and controlled by a third party who will not give me access to any files.

    I recreated the site and am using my own password encryption class, which allows for encryption and decryption.

    I looked up swift and it looks like it can do that job but on the site says nothing about sending hundreds or thousands of emails other then sending the same email to multiple people. I am wondering if this will e a problem.

    Here is an example of my script, I just simply replaced the mail() function with swifts send function. Wouldn't this cause the same problem?

    PHP Code:
    $users sql_query("SELECT * FROM users WHERE active=1");

    $mail = new Swift(new Swift_Connection_SMTP('localhost'));

    if(
    is_array($users)) {
        foreach(
    $users as $k=>$v) {
            
    $password generate_password();
            
    $encrypted text_crypt($password);
            
    //sql_query("UPDATE users SET password='$encrypted' WHERE userid='$v[userid]'");
            //Send the email
            
    $mail->send($v["email"], 'no-reply@mydomain.com''The subject''Your new password is: '.$password);
        }
    // foreach($users as $k=>$v)
    }// if(is_array($users))

    $mail->close(); 

  6. #6
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    see the anti flood plugin.

  7. #7
    SitePoint Addict
    Join Date
    Mar 2005
    Location
    California, US
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was looking into that but though it went off number of recipients in a single send.

    Assuming I am using
    Code:
    $mail->loadPlugin(new Swift_Plugin_AntiFlood(1, 10));
    If I have code like:
    Code:
      $mail->send('person1@email.com', 'no-reply@mydomain.com', 'The subject', 'The body');
      $mail->send('person2@email.com', 'no-reply@mydomain.com', 'The subject', 'The body');
      $mail->send('person3@email.com', 'no-reply@mydomain.com', 'The subject', 'The body');
      $mail->send('person4@email.com', 'no-reply@mydomain.com', 'The subject', 'The body');
    Will the anti span plug-in send line 1, wait 10 seconds, send line two, wait 10s, etc.? I was looking on the website and there is limited documentation on how this plug-in works.

  8. #8
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ill be honest ive never used that plugin, i use swift and ive seen it though.

    i took a brief look at the source code and it looks like it will do it.

    the purpose is to send multiple emails per connection though. you would probably want to specify something like 10-50 emails and then a sleep of 10 seconds. if you tell it to sleep after each email its going to reconnect to smtp after each email, which i is basically the same as calling mail() 6000 times with a call to sleep() in between each as far as efficiency goes. that kinda defeats the purpose of using it.

    if you specified 50, 10

    then it will connect to smtp, send 50 emails, disconnect, sleep for 10 seconds, reconnect and send the next 50 and so on.


    if you really wanted it to sleep between each email i suppose you could hack the onSend() function in antiflood.php and add sleep(1); to make it sleep between each email. i dont know if smtp servers like that though. or if you dont wanna hack the code up just create your own plugin and define an onSend() which just sleeps for a second, and load that plugin as well.

  9. #9
    SitePoint Addict
    Join Date
    Mar 2005
    Location
    California, US
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Each email's body contains user sensitive information to the specific user. I can't send one send() to 50 people. Each send needs to only go to the single user that the information int he body belongs to.

    I'm going to have to do more research on this. I'll probably run a test send to 500 bogus emails at my own domain to see what the load is like.

  10. #10
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you loop through an array of users, and still call send() for each user, providing thier own unique message.

    the plugin intercepts the send event and counts the time you call send()

    the plugin would be rather pointless if you couldnt send a different message to each email.

    just try it.


Bookmarks

Posting Permissions

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