Ejemplo n.º 1
0
 public function write($type, $message)
 {
     extract($this->config);
     if (empty($levels) || in_array($type, $levels)) {
         if ($duplicates || !$duplicates && strpos(file_get_contents($file), $message) === false) {
             try {
                 CakeEmail::deliver(null, 'An error has occurred: ' . $type, $message, $email);
                 if (!$duplicates) {
                     $output = $message . "\n";
                     file_put_contents($file, $output, FILE_APPEND);
                 }
             } catch (Exception $e) {
             }
         }
     }
 }
Ejemplo n.º 2
0
/**
 * testDeliver method
 *
 * @return void
 */
	public function testDeliver() {
		$instance = CakeEmail::deliver('*****@*****.**', 'About', 'Everything ok', array('from' => '*****@*****.**'), false);
		$this->assertInstanceOf('CakeEmail', $instance);
		$this->assertSame($instance->to(), array('*****@*****.**' => '*****@*****.**'));
		$this->assertSame($instance->subject(), 'About');
		$this->assertSame($instance->from(), array('*****@*****.**' => '*****@*****.**'));

		$config = array(
			'from' => '*****@*****.**',
			'to' => '*****@*****.**',
			'subject' => 'Update ok',
			'template' => 'custom',
			'layout' => 'custom_layout',
			'viewVars' => array('value' => 123),
			'cc' => array('*****@*****.**' => 'Myself')
		);
		$instance = CakeEmail::deliver(null, null, array('name' => 'CakePHP'), $config, false);
		$this->assertSame($instance->from(), array('*****@*****.**' => '*****@*****.**'));
		$this->assertSame($instance->to(), array('*****@*****.**' => '*****@*****.**'));
		$this->assertSame($instance->subject(), 'Update ok');
		$this->assertSame($instance->template(), array('template' => 'custom', 'layout' => 'custom_layout'));
		$this->assertSame($instance->viewVars(), array('value' => 123, 'name' => 'CakePHP'));
		$this->assertSame($instance->cc(), array('*****@*****.**' => 'Myself'));

		$configs = array('from' => '*****@*****.**', 'message' => 'Message from configs', 'transport' => 'Debug');
		$instance = CakeEmail::deliver('*****@*****.**', 'About', null, $configs, true);
		$message = $instance->message();
		$this->assertEquals($configs['message'], $message[0]);
	}
Ejemplo n.º 3
0
 public function forgotpassword()
 {
     if ($this->request->is('post')) {
         $this->loadModel('User');
         $mail = $this->request->data['UserForgotPassword']['frkUserEmail'];
         $data = $this->User->find('first', array('conditions' => array('frkUserEmail' => $mail), 'fields' => array('frkUserEmail', 'frkUserID')));
         if (!$data) {
             $msg = 'No Such E-mail address registerd with us';
             $this->Session->setFlash(__($msg));
             return $this->redirect(array('action' => 'forgotpassword'));
         } else {
             $key = $this->randStrGen(20);
             $sql = "UPDATE `users` SET `frkPasswordReset` =  '" . $key . "'  WHERE `users`.`frkUserID` = " . $data['User']['frkUserID'] . " ";
             $this->User->query($sql);
             $id = $data['User']['frkUserID'];
             $to = $data['User']['frkUserEmail'];
             $baseurl = Router::url('/', true);
             $link = $baseurl . "pages/reset/" . $key . "/" . $id;
             $subject = 'Reset password';
             $message1 = "Hello " . $to . "";
             $message2 = "\n Someone has requested a link to change your password. You can do this through the link below.";
             $message3 = "\n <a href='" . $link . "'></a>";
             $message4 = "\n If you didn't request this, please ignore this email.";
             $message5 = "\n Your password won't change until you access the link above and create a new one.";
             $message = $message1 . $message2 . $message3 . $message4 . $message5;
             $headers = 'From: info@farookadmission.in' . "\r\n" . 'Reply-To: info@farookadmission.in' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
             CakeEmail::deliver($to, $subject, $message, array('transport' => 'Smtp', 'from' => array('*****@*****.**' => 'Farook College PG Admission'), 'host' => 'email-smtp.us-west-2.amazonaws.com', 'tls' => true, 'port' => 587, 'timeout' => 30, 'username' => 'AKIAJJ62UMBPAOB3AAQA', 'password' => 'Ar12GanG4JddabSgQOQrQk0KFetnHANF5dwFx2vs/GmX', 'client' => null, 'log' => false));
             //$action = mail($to, $subject, $message, $headers);
             /*                 * ************* */
             $msg = 'Please check your email for reset instructions';
             $this->Session->setFlash(__($msg));
             /*if ($action) {
             
                                 
                             } else {
                                 $msg = 'Something went wrong with activation mail. Please try later';
             
                                 $this->Session->setFlash(__($msg));
                             }*/
         }
         $this->redirect('/');
     }
 }
Ejemplo n.º 4
0
/**
 * Sends the verification email
 *
 * This method is protected and not private so that classes that inherit this
 * controller can override this method to change the varification mail sending
 * in any possible way.
 *
 * @param string $to Receiver email address
 * @param array $options EmailComponent options
 * @return boolean Success
 */
	protected function _sendVerificationEmail($to = null, $options = array()) {
		$defaults = array(
			'from' => 'noreply@' . env('HTTP_HOST'),
			'subject' => __d('users', 'Account verification'),
			'template' => 'Users.account_verification');
		$options['from'] = '*****@*****.**';

		$options = array_merge($defaults, $options);

		$email = new CakeEmail();
		$email->to = $to;
		$email->from($options['from']);
		$email->subject($options['subject']);
		$email->template($options['template']);

		return $email->deliver($to, $options['subject'], $options['template'], array('from' => $options['from']));
	}
Ejemplo n.º 5
0
 /**
  * testDeliver method
  *
  * @return void
  */
 public function testDeliver()
 {
     $instance = CakeEmail::deliver('*****@*****.**', 'About', 'Everything ok', array('from' => '*****@*****.**'), false);
     $this->assertIsA($instance, 'CakeEmail');
     $this->assertIdentical($instance->to(), array('*****@*****.**' => '*****@*****.**'));
     $this->assertIdentical($instance->subject(), 'About');
     $this->assertIdentical($instance->from(), array('*****@*****.**' => '*****@*****.**'));
     $config = array('from' => '*****@*****.**', 'to' => '*****@*****.**', 'subject' => 'Update ok', 'template' => 'custom', 'layout' => 'custom_layout', 'viewVars' => array('value' => 123), 'cc' => array('*****@*****.**' => 'Myself'));
     $instance = CakeEmail::deliver(null, null, array('name' => 'CakePHP'), $config, false);
     $this->assertIdentical($instance->from(), array('*****@*****.**' => '*****@*****.**'));
     $this->assertIdentical($instance->to(), array('*****@*****.**' => '*****@*****.**'));
     $this->assertIdentical($instance->subject(), 'Update ok');
     $this->assertIdentical($instance->template(), array('template' => 'custom', 'layout' => 'custom_layout'));
     $this->assertIdentical($instance->viewVars(), array('value' => 123, 'name' => 'CakePHP'));
     $this->assertIdentical($instance->cc(), array('*****@*****.**' => 'Myself'));
 }