Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TextosController extends AppController {
- var $view = 'Theme';
- var $name = 'Textos';
- var $components = array('Email');
- function resolucoes($ano) {
- if (!isset($ano)) {
- $ano = '2011';
- }
- # ===— Instancie a classe e passe o path como parâmetro
- $folder = new Folder('files/resolucoes/'.$ano);
- # ===— Acesse o método find() da classe Folder e passe uma regex para procurar os arquivos
- $arquivos = $folder->find();
- # ===— Sete a variável para usar da forma que quiser na view
- $this->set('arquivos', $arquivos);
- }
- function contato() {
- }
- function enviaEmail () {
- $this->Email->IsSMTP();
- $this->Email->Host = "smtp.gmail.com";
- $this->Email->SMTPAuth = true;
- $this->Email->SMTPSecure = "ssl";
- $this->Email->Port = 465;
- $this->Email->Username = "*******@gmail.com";
- $this->Email->Password = "*********";
- $this->Email->SMTPDebug = 2;
- // the email content is just a (html) view in app/views/{controller}/emails/testmail.ctp
- $this->Email->renderBody('testeEmail');
- // assunto
- $this->Email->Subject = 'Test from example.com';
- // quem está enviando
- $this->Email->SetFrom('gcostajr@gmail.com', 'Test');
- // quem está recebendo
- $this->Email->AddAddress('gcostajr@gmail.com', 'Joe');
- $this->Email->AddAddress('gcostajr@gmail.com', 'Jane');
- if ($this->Email->Send()) {
- $this->redirect(array('controller' => 'textos', 'action' => 'contato'));
- }
- }
Add Comment
Please, Sign In to add comment