Remove configure::write('debug', 0); from your mail function and see actual error.
On Jun 7, 7:08 pm, andreguerreiro85 <andreguerreir...@gmail.com> wrote: > Hi there, i'm having a problem calling a function to send email inside > another function in a controller. i'm calling the function here on function > delete, the functions is mail(): > > function delete($id) > > { > $this->ApiHandler->access('admin', 'dcgl'); > > $this->EncomendasEncomenda->id = $id; > > $this->EncomendasEncomenda->recursive = -1; > > $data = $this->EncomendasEncomenda->read(); > > if ($data['EncomendasEncomenda']['activa'] == 1) > { > $newState = 0; > } > else > { > $newState = 1; > } > > if ($this->EncomendasEncomenda->saveField('activa', > $newState)) > > { > $this->mail($id); > $this->Session->setFlash('Estado da Encomenda > alterado'); > > } > else > { > $this->Session->setFlash('Não é possÃvel alterar o > estado da > Encomenda'); > } > $this->redirect($this->referer()); > } } > > My function mail() work's fine but when i call it from the function i get a > blank page and no email sended > > function mail($encomendaId) > { > configure::write('debug', 0); > > $this->autoRender = false; > > App::import('vendor', 'PHPMailer', array('file' => > 'PHPMailer_v5.0.2/class.phpmailer.php')); > > $mail = new PHPMailer(); > > $mail->SMTPDebug = 0; > > $mail->SMTPAuth = true; // enable SMTP > authentication > $mail->Port = 25; // set the SMTP port > > $mail->Host = Configure::read('Email.host'); // SMTP > server > > $mail->Username = Configure::read('Email.username'); // > SMTP account > username > > $mail->Password = Configure::read('Email.password'); // > SMTP account > password > > $mail->SetFrom(Configure::read('Email.address'), 'PCG'); > > $mail->AddAddress('andreguerre...@sogenave.pt', 'ADMIN'); > > $print_link = sprintf('http://%s%s', > configure::read('PCG.server'), > Router::url(array('action' => 'view', $encomendaId.'.print'))); > > $html = file_get_contents($print_link); > > if (empty($html)) > > { > $this->log('Envio do e-mail EMPTY ' . $print_link, 'emails'); > > exit(0); > > } > > $text = strip_tags($html); > > $subject = 'PCG: Encomenda #'.$encomendaId; > > $mail->Subject = $subject; > > $mail->AltBody = $text; > > $mail->MsgHTML($html); > > $this->log('Envio do e-mail ' . $subject, 'emails'); > > if(!$mail->Send()) > { > $this->log($mail->ErrorInfo, 'emails'); > } > else > { > $this->log('Envio do e-mail ' . $subject . ' OK', 'emails'); > } > > Thanks in advance. > > -- > View this message in > context:http://cakephp.1045679.n5.nabble.com/SEND-EMAIL-FUNCTION-INSIDE-CONTR... > Sent from the CakePHP mailing list archive at Nabble.com. -- 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php