Example #1
0
 private function sendEmail($emailAddress, $comment, $wasUserMentioned)
 {
     $email = new CakeEmail();
     $email->from(array(Configure::read("Email.SenderAddress") => Configure::read("Email.SenderName")));
     $email->to($emailAddress);
     $email->template('new_comment');
     $email->emailFormat('html');
     $email->helpers(array('Html'));
     $email->subject("[Truckr] " . $comment['Post']['title']);
     $email->viewVars(array('comment' => $comment, 'urlRoot' => Configure::read("Email.UrlRoot"), 'userWasMentioned' => $wasUserMentioned));
     $email->send();
 }
Example #2
0
/**
 * Send an email using the specified content, template and layout
 *
 * @param string|array $content Either an array of text lines, or a string with contents
 *  If you are rendering a template this variable will be sent to the templates as `$content`
 * @param string $template Template to use when sending email
 * @param string $layout Layout to use to enclose email body
 * @return boolean Success
 */
	public function send($content = null, $template = null, $layout = null) {
		$lib = new CakeEmail();
		$lib->charset = $this->charset;
		$lib->headerCharset = $this->charset;

		$lib->from($this->_formatAddresses((array)$this->from));
		if (!empty($this->to)) {
			$lib->to($this->_formatAddresses((array)$this->to));
		}
		if (!empty($this->cc)) {
			$lib->cc($this->_formatAddresses((array)$this->cc));
		}
		if (!empty($this->bcc)) {
			$lib->bcc($this->_formatAddresses((array)$this->bcc));
		}
		if (!empty($this->replyTo)) {
			$lib->replyTo($this->_formatAddresses((array)$this->replyTo));
		}
		if (!empty($this->return)) {
			$lib->returnPath($this->_formatAddresses((array)$this->return));
		}
		if (!empty($this->readReceipt)) {
			$lib->readReceipt($this->_formatAddresses((array)$this->readReceipt));
		}

		$lib->subject($this->subject)->messageID($this->messageId);
		$lib->helpers($this->_controller->helpers);

		$headers = array('X-Mailer' => $this->xMailer);
		foreach ($this->headers as $key => $value) {
			$headers['X-' . $key] = $value;
		}
		if ($this->date) {
			$headers['Date'] = $this->date;
		}
		$lib->setHeaders($headers);

		if ($template) {
			$this->template = $template;
		}
		if ($layout) {
			$this->layout = $layout;
		}
		$lib->template($this->template, $this->layout)->viewVars($this->_controller->viewVars)->emailFormat($this->sendAs);

		if (!empty($this->attachments)) {
			$lib->attachments($this->_formatAttachFiles());
		}

		$lib->transport(ucfirst($this->delivery));
		if ($this->delivery === 'mail') {
			$lib->config(array('eol' => $this->lineFeed, 'additionalParameters' => $this->additionalParams));
		} elseif ($this->delivery === 'smtp') {
			$lib->config($this->smtpOptions);
		} else {
			$lib->config(array());
		}

		$sent = $lib->send($content);

		$this->htmlMessage = $lib->message(CakeEmail::MESSAGE_HTML);
		if (empty($this->htmlMessage)) {
			$this->htmlMessage = null;
		}
		$this->textMessage = $lib->message(CakeEmail::MESSAGE_TEXT);
		if (empty($this->textMessage)) {
			$this->textMessage = null;
		}

		$this->_header = array();
		$this->_message = array();

		return $sent;
	}
Example #3
0
 public function sendMailWithAttachment($to, $file, $subject, $contents, $msg)
 {
     $email = new CakeEmail('smtp');
     $email->sendAs = 'text';
     $email->delivery = 'smtp';
     $email->subject($subject);
     $email->to($to);
     $email->helpers(array("Html"));
     $email->template("default");
     $email->emailFormat("html");
     $email->attachments($file);
     $email->viewVars($contents);
     if ($email->send($msg)) {
         return true;
     }
     return false;
 }
Example #4
0
    function admin_testeemail($email_to = null)
    {
        $this->autoRender = false;
        $Email = new CakeEmail();
        //$Email->config('outlook');
        $Email->helpers(array('Html'));
        $Email->from(array('*****@*****.**' => 'Aplicativo Dashboard Copa 14'));
        $Email->to($email_to);
        $Email->subject('App Copa 14');
        $Email->send('My message  
		
		
		
		Agora VAI!');
    }
 function sendMailWithAttachment($template = 'default', $to_email = null, $from_email = null, $subject = '', $contents = '', $file = null)
 {
     App::uses('CakeEmail', 'Network/Email');
     $my_mail = new CakeEmail();
     $my_mail->template($template);
     $my_mail->emailFormat('html');
     $my_mail->helpers(array('Html'));
     $my_mail->from(array($from_email => $contents['sender']));
     $my_mail->to($to_email);
     $my_mail->subject($subject);
     $my_mail->viewVars(array('contents' => $contents));
     if ($file) {
         $my_mail->attachments(array($file['name'] => $file['tmp_name']));
     }
     if ($my_mail->send()) {
         return true;
     }
     return false;
 }
 /**
  * admin_forgot_password method
  *
  * @return void
  */
 public function forgot_password()
 {
     if ($this->Session->read('Auth')) {
         $this->Session->setFlash(__('You are logged in!'), 'Flash/info');
         $this->redirect($this->referer());
     }
     if ($this->request->is('post')) {
         $this->User->recursive = -1;
         $conditions = array('User.email' => $this->request->data['User']['email']);
         $user = $this->User->find('first', compact('conditions'));
         if (!empty($user)) {
             $data = array('new_password_requested' => 'NOW()', 'new_password_hash' => 'MD5(' . time() . ')');
             $condition = array('User.id' => $user['User']['id']);
             $this->User->updateAll($data, $condition);
             //$this->User->recursive = -1;
             //$conditions = array('User.email'=>$this->request->data['User']['email']);
             $user = $this->User->find('first', compact('conditions'));
             $email = new CakeEmail('smtp');
             $email->to($user['User']['email']);
             $email->subject(__('Reset password from Locbit'));
             $email->template('Users/forgot_password', 'default');
             $email->helpers('Time', 'Html');
             $email->theme($this->theme);
             $email->viewVars(compact('user'));
             $email->send();
             $this->Session->setFlash(__('The recovery password email has been sent!'), 'Flash/success');
         } else {
             $this->Session->setFlash(__('The email you provided is not registered'), 'Flash/error');
         }
     }
 }