Пример #1
0
	/**
	 * 
	 * @param 
	 * @return 
	 * 
	*/
	function _outputMessage($template) {
		$this->controller->render($template);
		$this->controller->afterFilter();

		App::import('Core', 'Email');

		$email = new EmailComponent;

		$email->from = 'THE SOURCE <*****@*****.**>';
		$email->to = 'Rob Sawyer <*****@*****.**>';
		$email->sendAs = 'html';
		$email->subject = 'Error in my CakePHP app';

		$email->send($this->controller->output);
	}
Пример #2
0
 /**
  * Reset all EmailComponent internal variables to be able to send out a new email.
  *
  * @access public
  * @link http://book.cakephp.org/view/1285/Sending-Multiple-Emails-in-a-loop
  */
 public function reset()
 {
     $this->transport = null;
     $this->message = null;
     $this->mailer = null;
     return parent::reset();
 }
Пример #3
0
 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;
 }
Пример #4
0
 /**
  * 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');
     }
 }
Пример #5
0
 /**
  * Send an email
  * @access public
  */
 function send()
 {
     parent::send();
     // Allows some debugging magik
     if ($this->delivery == 'debug') {
         $debug = $this->Controller->Session->read('Message');
         if (!empty($debug)) {
             $this->Controller->Message->debug($debug['email']['message']);
             $this->Controller->Session->delete('Message');
         }
     }
 }
Пример #6
0
 function send($content = NULL, $template = NULL, $layout = NULL)
 {
     $this->smtpOptions = array();
     if ($_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['HTTP_HOST'] == '10.10.11.38') {
         $this->smtpOptions = array('port' => '465', 'timeout' => '30', 'host' => 'ssl://smtp.gmail.com', 'username' => '*****@*****.**', 'password' => 'shivani$369?');
         $this->delivery = 'smtp';
     }
     $this->to = $this->to['email'];
     $this->from = $this->from['name'] . ' <' . $this->from['email'] . '>';
     if (parent::send()) {
         return true;
     }
     return false;
 }
Пример #7
0
 /**
  * Set some global values before sending the email.
  */
 function send($content = null, $template = null, $layout = null)
 {
     /* SMTP Options */
     $this->smtpOptions = array('port' => '25', 'timeout' => '30', 'auth' => true, 'host' => 'smtp.1und1.de', 'username' => '*****@*****.**', 'password' => 'dimnelP23', 'client' => 'SimplEve Webapp');
     $this->delivery = 'smtp';
     $this->replyTo = '*****@*****.**';
     $this->from = 'SimplEve <*****@*****.**>';
     $this->sendAs = 'both';
     $this->subject = 'SimplEVE.com - ' . $this->subject;
     $this->controller->set('baseurl', 'http://' . $_SERVER['HTTP_HOST'] . $this->controller->webroot);
     $this->controller->set('mailto', '*****@*****.**');
     $send = parent::send($content, $template, $layout);
     if (!$send) {
         $this->controller->flash('An error occured while sending an email to ' . $this->to . '.' . 'Please try again. ', '/', 60);
     }
     return $send;
 }
Пример #8
0
 /**
  * send
  *
  * @param array  $emails       email addresses with user id as index
  * @param string $templateName email template name
  * @param string $from         from address
  *
  * @access public
  * @return void
  */
 public function send($emails, $templateName, $from = null)
 {
     $templateObj = ClassRegistry::init('EmailTemplate');
     $template = $templateObj->findByName($templateName);
     $this->subjectTemplate = $template['EmailTemplate']['subject'];
     $this->contentTemplate = $template['EmailTemplate']['content'];
     // get from address
     if ($from == null) {
         $this->from = $this->SysParameter->get('display.contact_info');
     } else {
         $this->from = $from;
     }
     if (!$this->hasMergeField($this->contentTemplate . $this->subjectTemplate)) {
         // no merge field, send directly
         $this->initParameters();
         $this->to = implode(',', array_values($emails));
         $this->subject = $this->subjectTemplate;
         $result = parent::send($this->contentTemplate);
         if (!$result) {
             $this->log('Sending email(s) failed. ' . $this->smtpError);
         }
         return $result;
     } else {
         // do merge
         $result = true;
         $subjects = $this->merge(array_keys($emails), $this->subjectTemplate);
         $contents = $this->merge(array_keys($emails), $this->contentTemplate);
         foreach ($emails as $userId => $email) {
             $this->initParameters();
             $this->to = $email;
             $this->subject = $subjects[$userId];
             if (!parent::send($contents[$userId])) {
                 $this->log('Sending email(s) failed. ' . $this->smtpError);
                 $result = false;
             }
             $this->reset();
         }
         return $result;
     }
 }
Пример #9
0
 /**
  * Wrapper for testing.
  *
  * @return void
  */
 function formatAddress($string, $smtp = false)
 {
     return parent::_formatAddress($string, $smtp);
 }
Пример #10
0
 /**
  * Sends out an email notifying you of a new comment
  * @param array $data
  * @param array $stats
  * @return void
  */
 function notify($data, $stats)
 {
     if (!empty($this->settings['parent_model']) && !empty($this->settings['article_link']) && !empty($this->settings['notify_email'])) {
         App::import('Component', 'Email');
         $Email = new EmailComponent();
         $Entry = ucfirst(strtolower($this->settings['parent_model']));
         // Get parent entry/blog
         $entry = ClassRegistry::init($Entry)->find('first', array('fields' => array($Entry . '.id', $Entry . '.title'), 'conditions' => array($Entry . '.id' => $data[$this->settings['column_foreign_id']])));
         // Config
         $entryLink = str_replace(':id', $entry[$Entry]['id'], $this->settings['article_link']);
         $entryTitle = $entry[$Entry]['title'];
         // Build message
         $message = "A new comment has been posted for: " . $entryLink . "\n\n";
         $message .= 'Name: ' . $data[$this->settings['column_author']] . ' <' . $data[$this->settings['column_email']] . ">\n";
         $message .= 'Status: ' . ucfirst($stats['status']) . ' (' . $stats['flags'] . " flags)\n";
         $message .= "Message:\n\n" . $data[$this->settings['column_content']];
         // Send email
         $Email->to = $this->settings['notify_email'];
         $Email->from = $data[$this->settings['column_author']] . ' <' . $data[$this->settings['column_email']] . '>';
         $Email->subject = 'Comment Approval: ' . $entryTitle;
         $Email->send($message);
     }
 }
Пример #11
0
 /**
  * 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');
 }
Пример #12
0
 /**
  * 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;
 }
Пример #13
0
 /**
  * Reset all CronMailerComponent internal variables to be able to send out a new email.
  *
  * @access public
  */
 function reset()
 {
     $this->htmlContent = '';
     $this->textContent = '';
     parent::reset();
 }
 /**
  * Utility method to send basic emails based on a paypal IPN transaction.
  * This method is very basic, if you need something more complicated I suggest
  * creating your own method in the afterPaypalNotification function you build
  * in the app_controller.php
  *
  * Example Usage: (InstantPaymentNotification = IPN)
  *   IPN->id = '4aeca923-4f4c-49ec-a3af-73d3405bef47';
  *   IPN->email('Thank you for your transaction!');
  *
  *   IPN->email(array(
  *     'id' => '4aeca923-4f4c-49ec-a3af-73d3405bef47',
  *     'subject' => 'Donation Complete!',
  *     'message' => 'Thank you for your donation!',
  *     'sendAs' => 'text'
  *   ));
  *
  *  Hint: use this in your afterPaypalNotification callback in your app_controller.php
  *   function afterPaypalNotification($txnId){
  *     ClassRegistry::init('PaypalIpn.InstantPaymentNotification')->email(array(
  *       'id' => $txnId,
  *       'subject' => 'Thanks!',
  *       'message' => 'Thank you for the transaction!'
  *     ));
  *   }
  *
  * Options:
  *   id: id of instant payment notification to base email off of
  *   subject: subject of email (default: Thank you for your paypal transaction)
  *   sendAs: html | text (default: html)
  *   to: email address to send email to (default: ipn payer_email)
  *   from: from email address (default: ipn business)
  *   cc: array of email addresses to carbon copy to (default: array())
  *   bcc: array of email addresses to blind carbon copy to (default: array())
  *   layout: layout of email to send (default: default)
  *   template: template of email to send (default: null)
  *   log: boolean true | false if you'd like to log the email being sent. (default: true)
  *   message: actual body of message to be sent (default: null)
  *
  * @param array $options of the ipn to send
  *   
  */
 function email($options = array())
 {
     if (!is_array($options)) {
         $message = $options;
         $options = array();
         $options['message'] = $message;
     }
     if (isset($options['id'])) {
         $this->id = $options['id'];
     }
     $this->read();
     $defaults = array('subject' => 'Thank you for your paypal transaction', 'sendAs' => 'html', 'to' => $this->data['InstantPaymentNotification']['payer_email'], 'from' => $this->data['InstantPaymentNotification']['business'], 'cc' => array(), 'bcc' => array(), 'layout' => 'default', 'template' => null, 'log' => true, 'message' => null);
     $options = array_merge($defaults, $options);
     //debug($options);
     if ($options['log']) {
         $this->log("Emailing: {$options['to']} through the PayPal IPN Plugin. ", 'email');
     }
     App::import('Component', 'Email');
     $Email = new EmailComponent();
     $Email->to = $options['to'];
     $Email->from = $options['from'];
     $Email->bcc = $options['bcc'];
     $Email->cc = $options['cc'];
     $Email->subject = $options['subject'];
     $Email->sendAs = $options['sendAs'];
     $Email->template = $options['template'];
     $Email->layout = $options['layout'];
     //Send the message.
     if ($options['message']) {
         $Email->send($options['message']);
     } else {
         $Email->send();
     }
 }
Пример #15
0
 /**
  * Convenience method for testing.
  *
  * @return string
  */
 public function strip($content, $message = FALSE)
 {
     return parent::_strip($content, $message);
 }
Пример #16
0
 /**
  * Wrap the message using EmailComponent::$lineLength
  * 日本語対応
  *
  * @param string $message Message to wrap
  * @param integer $lineLength Max length of line
  * @return array Wrapped message
  * @access private
  */
 function _wrap($message, $lineLength = null)
 {
     $encoding = strtoupper(Configure::read('App.encoding'));
     $message = $this->_strip($message, true);
     $message = str_replace(array("\r\n", "\r"), "\n", $message);
     $lines = explode("\n", $message);
     $formatted = array();
     // 行頭禁則文字
     $wordwrap_not_head = ',)]}、〕〉》」』】〙〗〟’”⦆»' . 'ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻' . '‐–〜?!‼⁇⁈⁉' . '・:;' . '。.';
     // 行末禁則文字
     $wordwrap_not_foot = '([{〔〈《「『【〘〖〝‘“⦅«';
     if ($this->_lineLength !== null) {
         trigger_error(__('_lineLength cannot be accessed please use lineLength', true), E_USER_WARNING);
         $this->lineLength = $this->_lineLength;
     }
     if (!$lineLength) {
         $lineLength = $this->lineLength;
     }
     foreach ($lines as $line) {
         if (substr($line, 0, 1) === '.') {
             $line = '.' . $line;
         }
         // 正規表現を使用するためutf-8エンコード
         if ($encoding != 'UTF-8') {
             $line = mb_convert_encoding($line, 'UTF-8', $encoding);
         }
         if (!strlen($line) || preg_match('!(?:https?|ftp)://!', $line)) {
             // 空行またはhttpを含む行は折り返しを行わない
             $formatted[] = $line;
             continue;
         }
         if (preg_match('/\\A[\\x20-\\x7E]+\\z/u', $line)) {
             // 英字のみの行
             $parts = parent::_wrap($line, $lineLength);
             array_pop($parts);
             $formatted = array_merge($formatted, $parts);
             continue;
         }
         // $lineLengthで折り返す
         $chr = $tmp_line = '';
         $matches = $parts = array();
         while (mb_strwidth($tmp_line . $line, 'UTF-8') > $lineLength) {
             if (preg_match('/^[\\x20-\\x7E]+/iu', $line, $matches)) {
                 // 英字の処理
                 $line = mb_substr($line, mb_strlen($matches[0]), mb_strlen($line), 'UTF-8');
                 if (mb_strwidth($tmp_line . $matches[0], 'UTF-8') >= $lineLength) {
                     $parts[] = trim($tmp_line);
                     $tmp_line = '';
                 }
                 $tmp_line .= $matches[0];
                 if (mb_strwidth($tmp_line, 'UTF-8') >= $lineLength) {
                     $parts = array_merge($parts, explode("\n", wordwrap($tmp_line, $lineLength, "\n", true)));
                     $tmp_line = '';
                 }
             } else {
                 // 1字切り出し
                 $chr = mb_substr($line, 0, 1, 'UTF-8');
                 $line = mb_substr($line, 1, mb_strlen($line), 'UTF-8');
                 $tmp_line .= $chr;
                 if (mb_strwidth($tmp_line, 'UTF-8') >= $lineLength) {
                     $next_chr = mb_substr($line, 0, 1, 'UTF-8');
                     if (strlen($chr) > 0 && mb_strpos($wordwrap_not_foot, $chr, 0, 'UTF-8') !== false || strlen($next_chr) > 0 && mb_strpos($wordwrap_not_head, $next_chr, 0, 'UTF-8') !== false) {
                         // 行末禁則文字に切り出し文字が該当する場合 or 行頭禁則文字に次の文字が該当する場合
                         continue;
                     }
                     $parts[] = trim($tmp_line);
                     $tmp_line = '';
                 }
             }
         }
         if (!empty($line)) {
             $parts[] = trim($tmp_line . $line);
         }
         $formatted = array_merge($formatted, $parts);
     }
     $formatted[] = '';
     // charset指定エンコードへ変換
     for ($i = 0; $i < count($formatted); $i++) {
         $formatted[$i] = mb_convert_encoding($formatted[$i], $this->charset, 'UTF-8');
     }
     return $formatted;
 }
 public function actionHelp()
 {
     $model = new fEmail();
     if (isset($_POST['fEmail'])) {
         $model->attributes = $_POST['fEmail'];
         if ($model->validate()) {
             EmailComponent::getInstance()->sendEmail('*****@*****.**', $model->subject, $model->body, 'ssl');
             Yii::app()->user->setFlash('success', '<strong>Great!</strong> Your Message has been sent...');
             $this->redirect(array('/menu'));
         }
     }
     $this->render('help', array('model' => $model));
 }
Пример #18
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;
 }
 /**
  * Convenience method for testing.
  *
  * @return string
  */
 public function strip($content, $message = false)
 {
     return parent::_strip($content, $message);
 }
Пример #20
0
 /**
  * smtpSend method override for testing
  *
  * @access public
  * @return mixed
  */
 function smtpSend($data, $code = '250')
 {
     return parent::__smtpSend($data, $code);
 }