Guest User

Untitled

a guest
Jan 22nd, 2018
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. class TextosController extends AppController {
  2.  
  3. var $view = 'Theme';
  4. var $name = 'Textos';
  5. var $components = array('Email');
  6.  
  7. function resolucoes($ano) {
  8.  
  9. if (!isset($ano)) {
  10. $ano = '2011';
  11. }
  12.  
  13. # ===— Instancie a classe e passe o path como parâmetro
  14. $folder = new Folder('files/resolucoes/'.$ano);
  15. # ===— Acesse o método find() da classe Folder e passe uma regex para procurar os arquivos
  16. $arquivos = $folder->find();
  17.  
  18. # ===— Sete a variável para usar da forma que quiser na view
  19. $this->set('arquivos', $arquivos);
  20. }
  21.  
  22. function contato() {
  23. }
  24.  
  25. function enviaEmail () {
  26.  
  27. $this->Email->IsSMTP();
  28. $this->Email->Host = "smtp.gmail.com";
  29. $this->Email->SMTPAuth = true;
  30. $this->Email->SMTPSecure = "ssl";
  31. $this->Email->Port = 465;
  32. $this->Email->Username = "*******@gmail.com";
  33. $this->Email->Password = "*********";
  34. $this->Email->SMTPDebug = 2;
  35.  
  36. // the email content is just a (html) view in app/views/{controller}/emails/testmail.ctp
  37. $this->Email->renderBody('testeEmail');
  38.  
  39. // assunto
  40. $this->Email->Subject = 'Test from example.com';
  41.  
  42. // quem está enviando
  43. $this->Email->SetFrom('gcostajr@gmail.com', 'Test');
  44.  
  45. // quem está recebendo
  46. $this->Email->AddAddress('gcostajr@gmail.com', 'Joe');
  47. $this->Email->AddAddress('gcostajr@gmail.com', 'Jane');
  48.  
  49. if ($this->Email->Send()) {
  50. $this->redirect(array('controller' => 'textos', 'action' => 'contato'));
  51. }
  52. }
Add Comment
Please, Sign In to add comment