本文整理汇总了PHP中Cake\Mailer\Email::deliver方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::deliver方法的具体用法?PHP Email::deliver怎么用?PHP Email::deliver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Mailer\Email
的用法示例。
在下文中一共展示了Email::deliver方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDeliver
/**
* testDeliver method
*
* @return void
*/
public function testDeliver()
{
$instance = Email::deliver('all@cakephp.org', 'About', 'Everything ok', ['from' => 'root@cakephp.org'], false);
$this->assertInstanceOf('Cake\\Mailer\\Email', $instance);
$this->assertSame($instance->to(), ['all@cakephp.org' => 'all@cakephp.org']);
$this->assertSame($instance->subject(), 'About');
$this->assertSame($instance->from(), ['root@cakephp.org' => 'root@cakephp.org']);
$config = ['from' => 'cake@cakephp.org', 'to' => 'debug@cakephp.org', 'subject' => 'Update ok', 'template' => 'custom', 'layout' => 'custom_layout', 'viewVars' => ['value' => 123], 'cc' => ['cake@cakephp.org' => 'Myself']];
$instance = Email::deliver(null, null, ['name' => 'CakePHP'], $config, false);
$this->assertSame($instance->from(), ['cake@cakephp.org' => 'cake@cakephp.org']);
$this->assertSame($instance->to(), ['debug@cakephp.org' => 'debug@cakephp.org']);
$this->assertSame($instance->subject(), 'Update ok');
$this->assertSame($instance->template(), ['template' => 'custom', 'layout' => 'custom_layout']);
$this->assertEquals($instance->viewVars(), ['value' => 123, 'name' => 'CakePHP']);
$this->assertSame($instance->cc(), ['cake@cakephp.org' => 'Myself']);
$configs = ['from' => 'root@cakephp.org', 'message' => 'Message from configs', 'transport' => 'debug'];
$instance = Email::deliver('all@cakephp.org', 'About', null, $configs, true);
$message = $instance->message();
$this->assertEquals($configs['message'], $message[0]);
}
示例2: registro
public function registro()
{
$usuario = $this->Usuarios->newEntity();
//\Cake\Log\Log::write( 'debug', __METHOD__.'['.__LINE__.']'.' POST= '.var_export($_POST, true));
//\Cake\Log\Log::write( 'debug', __METHOD__.'['.__LINE__.']'.' data= '.var_export( $this->request->data, true));
if ($this->request->is('post')) {
$usuario = $this->Usuarios->patchEntity($usuario, $this->request->data);
//\Cake\Log\Log::write( 'debug', __METHOD__.'['.__LINE__.']'.' usuario= '.var_export( get_class( $usuario), true));
//\Cake\Log\Log::write( 'debug', __METHOD__.'['.__LINE__.']'.' usuario= '.var_export( $usuario->__debugInfo(), true));
if ($this->Usuarios->save($usuario)) {
$url = 'http://' . $_SERVER['HTTP_HOST'] . '/recetas/cake/usuarios/activar-cuenta/' . $usuario['id'] . '/' . '0';
//\Cake\Log\Log::write( 'debug', __METHOD__.'['.__LINE__.']'.' url= '.var_export( $url, true));
Email::deliver($usuario['email'], 'Envío desde CakePHP', 'Pinche aquí para activar su cuenta:' . $url . '.', 'default', true);
$this->Flash->success(__('El usuario ha sido creado correctamente. Revise su correo para validar la cuenta'));
return $this->redirect($this->Auth->redirectUrl());
} else {
$this->Flash->error(__('No se ha podido crear el usuario. Inténtelo de nuevo.'));
}
}
$this->set(compact('usuario'));
$this->set('_serialize', ['usuario']);
}