code_junkie

How do I use the email component from a model in CakePHP?

Nov 12th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. $this->Email->delivery = 'smtp';
  2. $this->Email->template = 'default';
  3. $this->Email->sendAs = 'text';
  4. $this->Email->from = 'email';
  5. $this->Email->to = 'email';
  6. $this->Email->subject = 'Error';
  7.  
  8. App::import('Component', 'Email');
  9.  
  10. function _sendMail($to,$subject,$template) {
  11. $this->Email->to = $to;
  12. // $this->Email->bcc = array('[email protected]'); // copies
  13. $this->Email->subject = $subject;
  14. $this->Email->replyTo = '[email protected]';
  15. $this->Email->from = 'MyName <[email protected]>';
  16. $this->Email->template = $template;
  17. $this->Email->sendAs = 'text'; //Send as 'html', 'text' or 'both' (default is 'text')
  18. $this->Email->send();
  19. }
  20.  
  21. $this->_sendMail($this->data['User']['email'],'Thanks for registering!','register');
  22.  
  23. var $components = array('Email');
  24.  
  25. function sendEmail(&$controller) {
  26. App::import('Component', 'Email');
  27. $email = new EmailComponent();
  28. $email->startup($controller);
  29. }
  30.  
  31. var $components = array('Email');
  32.  
  33. $this->Email->delivery = ...
  34.  
  35. if(empty($this->MailsController)) {
  36. App::import('Controller','Mails');
  37. $this->MailsController = new MailsController();
  38. $this->MailsController->constructClasses();
  39. $this->MailsController->Email->startup($this->MailsController);
  40. }
  41.  
  42. $this->MailsController->orderMail($user_id,$this->id,$mode);
Add Comment
Please, Sign In to add comment