Send Separate Emails Simultaneously |
Hi,
First post on here - hopefully someone can help ![]() Using Codeigniter 3, I have a web form that sends an email to the site admin once a form is submitted - this works as expected. I am using email templates, once the form is submitted template 1 is sent (to the site admin). I would now like to simultaneously send template 2 (to the submitter's email address). The emails will contain the same content apart from the email intro text, and subject - details below; Email Template 1 - to admin; 'Hi, a new item has been requested on the site, ...' Email Template 2 - to submitter; 'Hi, Here is the item you have requested on the site, ...' My current code is as follows; Code: public function sendRequest() { Not sure what I need to add in order to send the second email template? Any help would be appreciated.
Before sending the second email you need to clear the email library. Otherwise it will reuse the provided settings from the first call
From the documentation Quote:Initializes all the email variables to an empty state. This method is intended for use if you run the email sending method in a loop, permitting the data to be reset between cycles CI_Email::clear
Hi Martin,
Thanks for the suggestion, I've already tried that and still only the first email is sending. Perhaps i'm not adding it in the correct place, if you could show an example of how it should look that may help. Thanks
You could have something like this
PHP Code: public function sendRequest() { You simply have to repeat all the steps required for sending an email in the first place. Only difference is that for the second call you need to call PHP Code: $this->email->clear(); And reset all the required config options Hope this helps you on your way ![]()
Perfect! Thank you
![]() I wasn't doing this part; Code: $this->email->from($from_email); // Update for second email
|
Welcome Guest, Not a member yet? Register Sign In |