Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 26th, 2012  |  syntax: PHP  |  size: 1.03 KB  |  views: 164  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public function testEmail() {
  2.                 $this->SwiftMailer->smtpHost = 'smtp.gmail.com';
  3.                 $this->SwiftMailer->smtpPort = 465;
  4.                 $this->SwiftMailer->smtpUsername = 'mlrepemi@gmail.com';
  5.                 $this->SwiftMailer->smtpPassword = 'secret_password';
  6.                
  7.                 $this->SwiftMailer->sendAs = 'html';
  8.                 $this->SwiftMailer->from = 'reynierpm@gmail.com';
  9.                 $this->SwiftMailer->fromName = 'New bakery component';
  10.                 $this->SwiftMailer->to = 'reynierpm@gmail.com';
  11.                
  12.                 //set variables to template as usual
  13.                 $this->set('message', 'My message');
  14.                  
  15.                 try {
  16.                         if(!$this->SwiftMailer->send('default', 'My subject')) {
  17.                                 $this->log("Error sending email");
  18.                         }
  19.                 }
  20.                 catch(Exception $e) {
  21.                         $this->log("Failed to send email: ".$e->getMessage());
  22.                 }
  23.                
  24.                 $this->redirect($this->referer(), null, true);
  25.                
  26. //              $email = new CakeEmail();
  27. //              $email->from(array('reynierpm@gmail.com' => __('Recruitment Job App')))
  28. //              ->to('reynierpm@gmail.com')
  29. //              ->subject(__('Recruitment Status Update'))
  30. //              ->send(__('Dear, ReynierPM this is a testing email'));
  31.         }
clone this paste RAW Paste Data