Mass email users their unique passwords

2k Views Asked by At

I have a database with 2k+ users and I want to send them their own passwords, but mass email it to them. The mass emailing can be done several ways, but the question is how to do it so each user gets his/her own unique password?

The user password is stored inside a field within a MySQL DB. And so does the email adress.

Appreciate any ideas.

3

There are 3 best solutions below

0
On

Well, I found the most flexible and easiest way to get this done is by using MailMerge inside MS WORD and then send out the messages.

Microsoft Word --> Mailings You have to extract the required data fields from the db and save them as an MS Excell file.

2
On

I want to send them their own passwords

NOOOOOO please don't

Seee e.g. the Password policy hall of shame:

Storing passwords in PLAIN TEXT is NOT SAFE.

It's time to make online services clean up their act!

Also: plaintextoffenders.com - "Did you just email me back my own password?!"

Sending clear-text passwords via E-Mail is considered a really, really bad practice. Passwords should be hashed; all users should be able to get through E-Mail is a link to reset it.

To answer your question though, you'd have to walk through each record, and send a custom E-Mail to each customer. That can be resource intensive, and/or bring down the machine if there's too many messages at once, so you'd have to wait in between sending each bunch. You could also use a 3rd party service like MailChimp.

0
On

Whats wrong with this approach (pseudo-code):

$result = sql_query ("SELECT id, email, username, password FROM users"); // get all users

$mailer = new SomeMailer();
while ($row = sql_fetch_row($result)) {
    $mailer->AddRecipient($row['email']);
    $mailer->AddBody("Hey, here is you pass LOL: " . $row['password']);
    $mail->Send();
}

That is how you can do it generally, I'd advise you to take Pekka's advice seriously though. Sending passwords in plain-text is a big no-no.