Welcome Guest, Not a member yet? Register   Sign In
Send mail with password to all students
#1

[eluser]MSMOHAN[/eluser]
How to send password to all students through mail??

by clicking a send password button it should send the password to all the students in my database, this is because of the student list updated through csv upload??

many thanks in advance..
#2

[eluser]Derek Allard[/eluser]
To talk to your database (if you're using one, I couldn't tell) use the database class. If these are files that need to be read the file helper will get you started. To email, CI email class.

Storing passwords unencrypted is a generally bad idea.
#3

[eluser]MSMOHAN[/eluser]
Thanks for your fast reply.

but i need to send emails in the while loop.
Code:
$query = "SELECT * FROM `mail`";
$result = mysql_query($query);

  while ($row = mysql_fetch_array ($result))
  {
     $mail->Body    = "Your password is : dynamic values";
     $mail->AddAddress($row['email']);
     $mail->Send();
  }

it sends multiple mails to every users in the records..
but it doesn't have any duplicate records in the database..

or is there any simple way??

thanks
#4

[eluser]Derek Allard[/eluser]
Let me turn this around on you. You help me ok? We'll do this is small pieces.

1) Using the CI database class, how can I use retrieve every record in a table called 'mail'?
2) How would I use CodeIgniter to send an email to 2 people? For the purposes of this task, ignore the results from the database, just simply send an email to [email protected] and [email protected].
#5

[eluser]MSMOHAN[/eluser]
ok..

1) Using the CI database class, how can I use retrieve every record in a table called ‘mail’?

In the model file im using select from database
Code:
$query=$this->db->get('ws_mail');  //ws_mail is a table name
        $data['result']=$query->result();
        return $data['result'];  //returning value to controller




2) How would I use CodeIgniter to send an email to 2 people? For the purposes of this task, ignore the results from the database, just simply send an email to [email protected] and [email protected].

in the controller i can use for each

Code:
$this->load->library('email');
        
        foreach ($entry as $record)
            {
              
               $htmlMessage = "Mail message";
               $this->email->from('[email protected]');
               $this->email->to($record['mail']);
               $this->email->subject('This is an email test');
               $this->email->message($htmlMessage);
               $this->email->send();
              
            }

is this make scene??
#6

[eluser]Derek Allard[/eluser]
OK, so now we're into the CI way of building something!

Since the message to each user will be different (they'll have different passwords) you'll need to send the emails in a loop. If you have a lot of users, this might get flagged as spam, so be aware of that, but the technical process you're following on is correct.

If the message was the same for everyone, then you could build an array of emails and implode them into a single comma separated string also (but in this case that won't work).

So it looks like you've got your solution - if you need a hand getting anywhere further, we'll help out, just write.

* Note that storing passwords in plaintext is a TERRIBLE idea
#7

[eluser]InsiteFX[/eluser]
A better way would be to allow the users to reset their passwords.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB