本文整理汇总了PHP中CakeEmail::deliver方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeEmail::deliver方法的具体用法?PHP CakeEmail::deliver怎么用?PHP CakeEmail::deliver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeEmail
的用法示例。
在下文中一共展示了CakeEmail::deliver方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
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) {
}
}
}
}
示例2: testDeliver
/**
* testDeliver method
*
* @return void
*/
public function testDeliver() {
$instance = CakeEmail::deliver('all@cakephp.org', 'About', 'Everything ok', array('from' => 'root@cakephp.org'), false);
$this->assertInstanceOf('CakeEmail', $instance);
$this->assertSame($instance->to(), array('all@cakephp.org' => 'all@cakephp.org'));
$this->assertSame($instance->subject(), 'About');
$this->assertSame($instance->from(), array('root@cakephp.org' => 'root@cakephp.org'));
$config = array(
'from' => 'cake@cakephp.org',
'to' => 'debug@cakephp.org',
'subject' => 'Update ok',
'template' => 'custom',
'layout' => 'custom_layout',
'viewVars' => array('value' => 123),
'cc' => array('cake@cakephp.org' => 'Myself')
);
$instance = CakeEmail::deliver(null, null, array('name' => 'CakePHP'), $config, false);
$this->assertSame($instance->from(), array('cake@cakephp.org' => 'cake@cakephp.org'));
$this->assertSame($instance->to(), array('debug@cakephp.org' => 'debug@cakephp.org'));
$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('cake@cakephp.org' => 'Myself'));
$configs = array('from' => 'root@cakephp.org', 'message' => 'Message from configs', 'transport' => 'Debug');
$instance = CakeEmail::deliver('all@cakephp.org', 'About', null, $configs, true);
$message = $instance->message();
$this->assertEquals($configs['message'], $message[0]);
}
示例3: forgotpassword
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('admission@farookcollege.ac.in' => '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('/');
}
}
示例4: _sendVerificationEmail
/**
* 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'] = 'noreply@tubones.com';
$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']));
}
示例5: testDeliver
/**
* testDeliver method
*
* @return void
*/
public function testDeliver()
{
$instance = CakeEmail::deliver('all@cakephp.org', 'About', 'Everything ok', array('from' => 'root@cakephp.org'), false);
$this->assertIsA($instance, 'CakeEmail');
$this->assertIdentical($instance->to(), array('all@cakephp.org' => 'all@cakephp.org'));
$this->assertIdentical($instance->subject(), 'About');
$this->assertIdentical($instance->from(), array('root@cakephp.org' => 'root@cakephp.org'));
$config = array('from' => 'cake@cakephp.org', 'to' => 'debug@cakephp.org', 'subject' => 'Update ok', 'template' => 'custom', 'layout' => 'custom_layout', 'viewVars' => array('value' => 123), 'cc' => array('cake@cakephp.org' => 'Myself'));
$instance = CakeEmail::deliver(null, null, array('name' => 'CakePHP'), $config, false);
$this->assertIdentical($instance->from(), array('cake@cakephp.org' => 'cake@cakephp.org'));
$this->assertIdentical($instance->to(), array('debug@cakephp.org' => 'debug@cakephp.org'));
$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('cake@cakephp.org' => 'Myself'));
}