On Tue, Oct 6, 2009 at 1:50 PM, Dave Maharaj :: WidePixels.com <d...@widepixels.com> wrote: > My controller is getting out of control.... > > I have 3 different registration functions which all send emails > > such as: > > if ($this->User->save($this->data, true, > array_intersect(array_keys($this->User->schema()), $white))) { > $this->Email->smtpOptions = array(my info here); > $this->Email->delivery = 'smtp'; > $this->Email->to = $this->data['User']['email']; > $this->Email->subject = 'Account Confirmation'; > $this->Email->replyTo = 'noreply@; > $this->Email->from = '<admin@>; > $this->Email->sendAs = 'html'; > $this->Email->template = 'registration'; > $this->set('data', $this->data); > $this->set('ip_address', $_SERVER['REMOTE_ADDR']); > $this->set('server_name', $_SERVER['SERVER_NAME']); > > if ($this->Email->send()) { > do something here but each registration does something > different > } > > I need to turn this into a function which will return true or false if > $this->Email->send() to continue on. > > Any ideas? I tred a few things but it never worked. > > > > function sendRegistrationEmail($data, $role) { > $sendSuccess = false; > /* SMTP Options */ > ....... > > if ($this->Email->send()) { > $sendSuccess = true; > //create the Freelancer page > } > return $sendSuccess; > > } > > Dave
if ($this->User->save(...)) { // email stuff $data = array( 'subject' => '...', 'to' => '...' // etc. ); if ($this->sendRegistrationEmail($data)) { // do your role stuff here } } function sendRegistrationEmail($data) { $this->Email->subject = $data['subject']; // etc. return $this->Email->send(); } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---