Try logging or outputting $this->Email->smtpError to see if you have
any problems there.
Also check the return from Email->send() mostly just to see that it
actually runs.
On May 20, 4:07 am, "Dave Maharaj :: WidePixels.com"
wrote:
> I have a function where it saves data to the database and emails a user.
> The function is called using AJAX
> The email is going to me so its a valid email address for testing purposes,
> I have debug on the save function so I can see the data being saved. AJAX
> returns success message, the data is saved but the email is only sent
> sometimes.
>
> Ideas why it would work sometimes and not other times? Basically the page
> loads and if the user has no record in the database then it displays the
> AJAX link so its only visible when needed. Click the link it saved the
> data...email is sent sometimes?
>
> Just wondering if there would be a reason why it would only send the email
> sometimes even though no error is reported?
>
> function save($id)
> {
>
> if ($this->RequestHandler->isAjax()) {
> $record =
> $this->Applicant->checkApplicant($this->Auth->user('id')]);
> if ($record == '0') {
> $this->Applicant->create();
> if ($this->Applicant->save($this->data, true,
> array_keys($this->Applicant->schema( {
> $user =
> $this->Applicant->User->getEmailInfo($this->Auth->user('id'));
> /* SMTP Options */
> $this->Email->smtpOptions = array('port' => 'xxx',
> 'timeout' => '30', 'host' => 'localhost', 'username' => 'xxx',
> 'password' => 'xxx');
> /* Set delivery method */
> $this->Email->delivery = 'smtp';
> $this->Email->to = $user['User']['email'];
> //$this->Email->to = 'd...@widepixels.com';
> $this->Email->subject = 'Welcome!';
> $this->Email->replyTo = 'nore...@widepixels.com';
> $this->Email->from = 'widepixels.com
> ';
> $this->Email->sendAs = 'html';
> $this->Email->template = 'welcome';
> $this->set(compact( 'record','user'));
> $this->Email->send();
> }
> }
> $this->set(compact('applied'));
> $this->set('value', 'You have successfuly registered.');
> $this->layout = 'ajax';
> }else {
> $this->layout = 'ajax';
> $this->render('/errors/reg_error');
> }
> }
>
> Dave
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---