Not sure what the answer is then I'm afraid. Someone with more Cake experience may be able to see an issue. As far as I can see the code is similar to what is working for me with different email templates.
I've never tried calling one email function from another, so maybe that is causing the issue. But it seems that the reset call should avoid any issues with this. Otherwise, maybe the default.ctp naming will cause an issue? As default.ctp carries some significance to CakePHP. On Jun 4, 1:25 pm, Niels <[email protected]> wrote: > Hey thanks for the response, > > no it wasn't a typo, so I tried and copied the templates in the \app > \views\elements\email\text folder. > But still no luck. Any other advise on how the make t'is work ? > > On Jun 3, 10:03 am, chris <[email protected]> wrote: > > > > > > > > > First thing I noticed was thatemailtemplatesshould be in > > > \app\views\elements\email\text (and/or \html) > > > Maybe just a typo in your message, but thought I start there. > > > On Jun 2, 4:20 pm, Niels <[email protected]> wrote: > > > > Hey everybody, I'm setting up a contact form. I want to send 2email > > > at once. One to contact person as confirmation and one to the person > > > handling the contact request. > > > > I setup up 2templatesin the /app/view/layout/text folder > > > internal_message.ctp and default.ctp. > > > > I'm receiving the mails but the template us the same in both cases. > > > And I'm sure I specified the right template. > > > This is the code I'm using: > > > > function index(){ > > > if(isset($this->data)) { > > > $contact = $this->Contact->create($this->data); > > > > if($this->Contact->validates()){ > > > > $smtpOptions = array( > > > 'port'=> Configure::read('Settings.mail_port'), > > > 'timeout'=> > > > Configure::read('Settings.mail_timeout'), > > > 'host' => > > > Configure::read('Settings.mail_host'), > > > 'username'=> > > > Configure::read('Settings.mail_username'), > > > 'password'=> > > > Configure::read('Settings.mail_password'), > > > ); > > > > $this->_internalResponse($contact,$smtpOptions); > > > > $this->redirect(array('action' => 'index')); > > > } else { > > > $this->Session->setFlash('Please Correct Errors'); > > > //$this->redirect('/contacts'); > > > } > > > } > > > } > > > > function _autoResponse($data,$smtpOptions) > > > { > > > $this->Email->reset(); > > > > $this->Email->smtpOptions = $smtpOptions; > > > $this->Email->delivery = 'smtp'; > > > //$this->Email->delivery = 'debug'; > > > > $this->Email->to = $this->data['Contact']['name'].' <'. > > > $this->data['Contact']['email'].'>'; > > > $this->Email->from = '[email protected]'; > > > $this->Email->subject = 'Prevaes contact betreft: '. > > > $this->data['Contact']['subject']; > > > > $this->Email->template = 'default'; > > > $this->Email->sendAs = 'text'; > > > > $this->set('Contact',$data); > > > > if ($this->Email->send()) { > > > $this->Session->setFlash('Bedankt om contact met > > > ons op te nemen, </br> een kopie zal naar uw inbox gestuurd worden.'); > > > > //$this->redirect('/'); > > > } else { > > > $this->Session->setFlash('Mail Not Sent'); > > > //$this->set('smtp_errors', $this->Email->smtpError); > > > > } > > > } > > > > function _internalResponse($data,$smtpOptions) > > > { > > > $this->Email->reset(); > > > > $this->Email->smtpOptions = $smtpOptions; > > > $this->Email->delivery = 'smtp'; > > > > $this->Email->to = > > > Configure::read('Settings.mail_username'); > > > $this->Email->from = $this->data['Contact']['name'].' > > > <'.$this->data['Contact']['email'].'>'; > > > $this->Email->subject = 'Prevaes internal contact: '. > > > $this->data['Contact']['subject']; > > > > $this->Email->template = 'internal_message'; > > > $this->Email->sendAs = 'text'; > > > > $this->set('Contact',$data); > > > > if ($this->Email->send()) { > > > $this->_autoResponse($data, $smtpOptions); > > > } else { > > > $this->Session->setFlash('Mail Not Sent'); > > > //$this->set('smtp_errors', $this->Email->smtpError); > > > > } > > > } > > > > I'm using 2 private method to create end send the 2 different mails. > > > As you can see in both cases I specified > > > $this->Email->template = 'default'; > > > $this->Email->sendAs = 'text'; > > > I know that sendAs isn't strictly necessary because it's default. But > > > I thought that could be the reason. > > > And I perform a $this->Email->reset(); to make sure the properties of > > > theemailare reset. > > > > Does any one know how to fix this or see an error in my code ? > > > > Thanks a lot in advance. > > > > Regards, > > > > Niels -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
