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' => 'xxxxxxxxxxxxxxx',
'password' => 'xxxxxxxxxxxxxxx');
                      /* Set delivery method */
                      $this->Email->delivery = 'smtp';
                      $this->Email->to = $user['User']['email'];
                      //$this->Email->to = '[email protected]';
                      $this->Email->subject = 'Welcome!';
                      $this->Email->replyTo = '[email protected]';
                      $this->Email->from = 'widepixels.com
<[email protected]>';
                      $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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to