• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Same form to different e-mail addresses and not the same content

[eluser]Elias Rufino[/eluser]
Hello guys.

I have some forms, and when the user send it, some get an e-mail. This works fine.

I need to send a confirmation to the user that the form was filled and it was ok. And I need to send another e-mail to another person, with nearly the same data, but with things a little different.

So, how can I send two e-mails, to two different people and with different content, using the data from a single form?

Thanks in advance,


[eluser]Elias Rufino[/eluser]
If I use
will I lost the form data?

No, it only clears the data in the email class, but I'm not sure if you need it. It will reset the entire email object.

Have you tried sending the first email and then just overriding these fields and send a second time with the new formatting?

post your code...

[eluser]Elias Rufino[/eluser]
I will try some things and post it asap.

Thank you for your attention,


[eluser]Elias Rufino[/eluser]
Hello again guys. It's solved.

I will not post the form code, but if someone needs it, just tell me.

I have some validation to this form, the controller do that. So, I have things like that:

public function index()
        $output[] = NULL;
        // (...) - There are some things here, like captcha...
if ($this->form_validation->run() === FALSE)
            $output['content'] = $this->load->view('contact', $data, TRUE);
            $mail['ip'] = $this->input->server("REMOTE_ADDR");
            $mail['date'] = date('d/m/Y H:i:s');
            $mail['subject'] = $this->input->post('subject', TRUE);
            $mail['name'] = $this->input->post('name');
            $mail['email'] = $this->input->post('email');
            $mail['phone'] = $this->input->post('phone');
            $mail['msg'] = $this->input->post('msg', TRUE);


            $this->email->from('[email protected]', 'Name from sender');
            $this->email->to('[email protected]');

            $this->email->message("IP: ".$mail['ip'].
                                  "\nDate: ".$mail['date'].
                                  "\nName: ".$mail['name'].
                                  "\nE-Mail: ".$mail['email'].
                                  "\nPhone: ".$mail['phone'].
                                  "\nSubject: ".$mail['subject'].
                                  "\n\nMessage: \n".$mail['msg']);

            $this->email->send(); // Here the first e-mail is sent

            $msg1 = 'Hello ';
            $msg2 = '. Great to receive your contact. We will call you as soon as possible.';

            $this->email->from('[email protected]', 'Your Contact');
            $this->email->to($mail['email']); // will send the new mail to the address person filled in the form

            $this->email->subject($mail['subject']); // or can use another subject, just to test
            $this->email->message("Data: ".$mail['data'].
                                  "\nNice to talk to you - www.yoursite.com");


            $this->session->set_flashdata('success', 'Success. Your contact was sent.');

            redirect(site_url('contact'), 'location');

  $this->load->view('layouts/default', $output);

So, CroNiX give me the tip and it really works. I can just run and send it in a normal way, after the first e-mail is sent.

It's just a test, the message to the second e-mail should be better organized.

Thank you very much.



Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.