public function run($data)
 {
     $this->Controller =& new Controller();
     $this->Email =& new EmailComponent(null);
     $this->Email->initialize($this->Controller, $this->defaults);
     if (array_key_exists('settings', $data)) {
         $this->Email->_set(array_filter(am($this->defaults, $data['settings'])));
         if (array_key_exists('vars', $data)) {
             foreach ($data['vars'] as $name => $var) {
                 $this->Controller->set($name, $var);
             }
         }
         return $this->Email->send();
     }
     $this->err('Queue Email task called without settings data.');
     return false;
 }
 /**
  * Initialize component
  *
  * @param object $controller Instantiating controller
  * @access public
  */
 function initialize(&$controller, $settings = array())
 {
     parent::initialize($controller, $settings);
     if (Configure::read('Postmark.uri') !== null) {
         $this->uri = Configure::read('Postmark.uri');
     }
     if (Configure::read('Postmark.key') !== null) {
         $this->key = Configure::read('Postmark.key');
     }
 }
Exemple #3
0
 /**
  * Initialize component
  * @param $controller
  * @param $settings
  * @return void
  */
 function initialize(&$controller, $settings = array())
 {
     parent::initialize($controlller, $settings);
     $this->Controller = $controller;
     // delivery configuration
     $this->delivery = Configure::read('App.mailer.delivery');
     if ($this->delivery == 'smtp') {
         $this->smtpOptions = Configure::read('App.mailer.smtpOptions');
     }
     // default content header
     $this->replyTo = Configure::read('App.mailer.default.replyTo');
     $this->from = Configure::read('App.mailer.default.from');
     $this->sendAs = Configure::read('App.mailer.default.format');
     $this->xMailer = 'PHP Mailer Component';
 }
 /**
  * Initialize component
  * 
  * @param object $controller Instantiating controller
  * @param array $settings Component settings
  */
 function initialize(&$controller, $settings = array())
 {
     parent::initialize($controller, $settings);
     $this->delivery = 'db';
     $this->QueuedEmail = ClassRegistry::init('CronMailer.QueuedEmail');
 }
 /**
  * undocumented
  *
  */
 function &_loadEmail()
 {
     App::import('Component', 'Email');
     $Email = new EmailComponent();
     $Email->initialize($this);
     $from = $this->Project->from();
     $Email->from = 'Chaw ' . $from;
     $Email->replyTo = 'Chaw ' . $from;
     $Email->return = $from;
     return $Email;
 }
Exemple #6
0
 /**
  * Wrapper around the email component, simplifying sending the kinds of emails we want to send.
  *
  * @param mixed $opts Array of options controlling the email.
  * @return mixed true if the email was sent, false otherwise.
  *
  */
 function _sendMail($opts)
 {
     App::import('Component', 'Email');
     $email = new EmailComponent();
     // Set up default values where applicable
     if (!array_key_exists('from', $opts)) {
         $opts['from'] = Configure::read('email.admin_name') . ' <' . Configure::read('email.admin_email') . '>';
     }
     // Set some details from the configuration
     if (Configure::read('email.use_smtp')) {
         $opts['delivery'] = 'smtp';
         $opts['smtpOptions'] = array_merge($email->smtpOptions, Configure::read('email.smtp_options'));
     }
     if (Configure::read('email.debug')) {
         $opts['delivery'] = 'debug';
     }
     // We may have been given complex Person arrays that the sender wants us to extract details from
     foreach (array('to' => true, 'cc' => true, 'bcc' => true, 'from' => false, 'replyTo' => false) as $key => $array) {
         if (array_key_exists($key, $opts)) {
             $opts[$key] = $this->_extractEmails($opts[$key], $array);
         }
     }
     // If there are no recipients, don't even bother trying to send
     if (empty($opts['to'])) {
         return array_key_exists('ignore_empty_address', $opts) && $opts['ignore_empty_address'];
     }
     // Add any custom headers
     if (array_key_exists('header', $opts)) {
         $email->header($opts['header']);
     }
     // Check if there are attachments to be included
     $email->attachments = Configure::read('email.attachments');
     if (empty($email->attachments)) {
         $email->attachments = array();
     }
     if (!empty($opts['attachments'])) {
         $email->attachments = array_merge($email->attachments, $opts['attachments']);
     }
     if (!empty($email->attachments)) {
         $email->filePaths = Configure::read('email.attachment_paths');
     }
     // Get ready and send it
     $email->initialize($this, $opts);
     if (array_key_exists('content', $opts)) {
         $success = $email->send($opts['content']);
     } else {
         $success = $email->send();
     }
     if (!empty($email->smtpError)) {
         $this->log("smtp-errors: {$email->smtpError}");
     }
     return $success;
 }