sending emails to user with id extracted from array

I have code which import CSV data in mysql with php, import is working fine but i need additional function which will send email to user by searching user_id from csv. I had converted csv to array $csv_array,

user_id     order    part

1           test     phone
1           another  pad
2           all      tab

Now, code will search user and get user_email from user database and then send email to user.

foreach ($csv_array as $row) {


                $email = $this->admin_model->getEmailNotification();

                $user = $this->model->getUserShipment($row['user_id']);

                if(count($user) == 1)
                    $data = array(  
                        'user_firstname' => $user->user_firstname,
                        'user_lastname' => $user->user_lastname,
                        'user_email' => $user->user_email,

                    $subject = 'Your Order has been shipped';
                    $message = $this->parser->parse('templates/update', $data, TRUE);

                    $config['protocol'] = $email->email_protocol;
                    $config['smtp_host'] = $email->email_host;
                    $config['smtp_user'] = $email->email_address;
                    $config['smtp_pass'] = $email->email_password;
                    $config['smtp_port'] = $email->email_port;
                    $config['newline']    = "\r\n";





Now with this i have two problems,

  1. This will send email for each row, but i want to send only 1 email with two orders, example, in above table, user_id 1 will get only 1 email with order and part information,

  2. Also, how will i create array to pass in template for user_id-1 -> order and parts to put in table inside template?



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s