本文整理汇总了PHP中Cake\Mailer\Email::template方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::template方法的具体用法?PHP Email::template怎么用?PHP Email::template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Mailer\Email
的用法示例。
在下文中一共展示了Email::template方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendSocialValidationEmail
/**
* Send social validation email to the user
*
* @param EntityInterface $socialAccount social account
* @param EntityInterface $user user
* @param Email $email Email instance or null to use 'default' configuration
* @return mixed
*/
public function sendSocialValidationEmail(EntityInterface $socialAccount, EntityInterface $user, Email $email = null)
{
if (empty($email)) {
$template = 'CakeDC/Users.social_account_validation';
} else {
$template = $email->template()['template'];
}
$this->getMailer('CakeDC/Users.Users', $this->_getEmailInstance($email))->send('socialAccountValidation', [$user, $socialAccount, $template]);
}
示例2: testQueue
public function testQueue()
{
$queue = TableRegistry::get('CodeBlastrQueue.Queues');
$countBefore = $queue->find('all')->count();
$email = new Email();
$email->template('default', 'default')->to('sample@example.com')->subject('About Me')->send();
if (!empty($email)) {
$countAfter = $queue->find('all')->count();
}
$this->assertTrue($countBefore < $countAfter);
}
示例3: sendPasswordResetEmail
/**
* Sends an email with a link that can be used in the next
* 24 hours to give the user access to the password-reset page
*
* @param int $userId
* @return boolean
*/
public static function sendPasswordResetEmail($userId)
{
$timestamp = time();
$hash = Mailer::getPasswordResetHash($userId, $timestamp);
$resetUrl = Router::url(['prefix' => false, 'controller' => 'Users', 'action' => 'resetPassword', $userId, $timestamp, $hash], true);
$email = new Email();
$usersTable = TableRegistry::get('Users');
$user = $usersTable->get($userId);
$email->template('reset_password')->subject('MACC website password reset')->to($user->email)->viewVars(compact('user', 'resetUrl'));
return $email->send();
}
示例4: mailer
/**
* mailer method
*
* @param array $data Dados para formar o email.
* @return boolean True ou False.
*/
public function mailer($data, $template, $subject)
{
$email = new Email();
$email->transport('mailSgl');
$email->emailFormat('html');
$email->template($template);
$email->from('sglmailer@gmail.com', 'SGL');
$email->to($data['email'], $data['nome']);
$email->viewVars($data);
$email->subject($subject);
$email->send();
}
示例5: testSendWithEmail
/**
* @return void
*/
public function testSendWithEmail()
{
$config = ['transport' => 'queue', 'charset' => 'utf-8', 'headerCharset' => 'utf-8'];
$this->QueueTransport->config($config);
$Email = new Email($config);
$Email->from('noreply@cakephp.org', 'CakePHP Test');
$Email->to('cake@cakephp.org', 'CakePHP');
$Email->cc(['mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso']);
$Email->bcc('phpnut@cakephp.org');
$Email->subject('Testing Message');
$Email->attachments(['wow.txt' => ['data' => 'much wow!', 'mimetype' => 'text/plain', 'contentId' => 'important']]);
$Email->template('test_template', 'test_layout');
$Email->subject("L'utilisateur n'a pas pu être enregistré");
$Email->replyTo('noreply@cakephp.org');
$Email->readReceipt('noreply2@cakephp.org');
$Email->returnPath('noreply3@cakephp.org');
$Email->domain('cakephp.org');
$Email->theme('EuroTheme');
$Email->emailFormat('both');
$Email->set('var1', 1);
$Email->set('var2', 2);
$result = $this->QueueTransport->send($Email);
$this->assertEquals('Email', $result['job_type']);
$this->assertTrue(strlen($result['data']) < 10000);
$output = json_decode($result['data'], true);
$emailReconstructed = new Email($config);
foreach ($output['settings'] as $method => $setting) {
call_user_func_array([$emailReconstructed, $method], (array) $setting);
}
$this->assertEquals($emailReconstructed->from(), $Email->from());
$this->assertEquals($emailReconstructed->to(), $Email->to());
$this->assertEquals($emailReconstructed->cc(), $Email->cc());
$this->assertEquals($emailReconstructed->bcc(), $Email->bcc());
$this->assertEquals($emailReconstructed->subject(), $Email->subject());
$this->assertEquals($emailReconstructed->charset(), $Email->charset());
$this->assertEquals($emailReconstructed->headerCharset(), $Email->headerCharset());
$this->assertEquals($emailReconstructed->emailFormat(), $Email->emailFormat());
$this->assertEquals($emailReconstructed->replyTo(), $Email->replyTo());
$this->assertEquals($emailReconstructed->readReceipt(), $Email->readReceipt());
$this->assertEquals($emailReconstructed->returnPath(), $Email->returnPath());
$this->assertEquals($emailReconstructed->messageId(), $Email->messageId());
$this->assertEquals($emailReconstructed->domain(), $Email->domain());
$this->assertEquals($emailReconstructed->theme(), $Email->theme());
$this->assertEquals($emailReconstructed->profile(), $Email->profile());
$this->assertEquals($emailReconstructed->viewVars(), $Email->viewVars());
$this->assertEquals($emailReconstructed->template(), $Email->template());
//for now cannot be done 'data' is base64_encode on set but not decoded when get from $email
//$this->assertEquals($emailReconstructed->attachments(),$Email->attachments());
//$this->assertEquals($Email, $output['settings']);
}
示例6: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
$this->set('menuActivo', 'actividad');
$this->Crud->on('afterSave', function (\Cake\Event\Event $event) {
if ($event->subject->created) {
$email = new Email();
$email->template('default')->emailFormat('html')->to('alvaro89mr@gmail.com')->from('alvaro89mr@gmail.com')->viewVars(['actividad' => $this->request->data])->send();
$this->_compruebaMaximoActividadesPorCurso($this->request->data['curso']['_ids']);
if ($this->request->data['destacada'] == '1') {
$idActividad = $event->subject->entity->id;
$this->_guardaDestacado($idActividad);
}
}
});
}
示例7: sendNewMissionsToInterestedUsers
public function sendNewMissionsToInterestedUsers($nbrDays = 7)
{
$created = Time::now()->subDays($nbrDays);
$missions = $this->Missions->find('all', ['conditions' => ['Missions.created >=' => $created]])->toArray();
$newMissions = [];
foreach ($missions as $mission) {
$users = $this->Users->find('all')->toArray();
foreach ($users as $user) {
$usersTypeMissions = $this->UsersTypeMissions->findByUserId($user['id'])->toArray();
foreach ($usersTypeMissions as $userTypeMissions) {
// Check if the current mission has the same type has the current userType mission
if ($userTypeMissions['type_mission_id'] == $mission['type_mission_id']) {
// Add a new mission to the list of missions to send
if (isset($newMissions[$user['email']])) {
$newMission = [];
$newMission['link'] = Router::url(['controller' => 'Missions', 'action' => 'view', $mission['id']]);
$newMission['name'] = $mission['name'];
//print("Mission " . $newMission['name'] . " added to user " . $user['email'] . "\n");
array_push($newMissions[$user['email']], $newMission);
} else {
//print("Creating mission list for user " . $user['email'] . "\n");
$newMissions[$user['email']] = [];
$newMission = [];
$newMission['link'] = Router::url(['controller' => 'Missions', 'action' => 'view', $mission['id']]);
$newMission['name'] = $mission['name'];
//print("Mission " . $newMission['name'] . " added to user " . $user['email'] . "\n");
array_push($newMissions[$user['email']], $newMission);
}
}
}
}
}
// For each user send their associated list of missions
foreach ($newMissions as $userEmail => $missionsToSend) {
$email = new Email();
$email->domain('maisonlogiciellibre.org');
$email->to($userEmail);
$email->subject('New missions available at ML2');
$email->template('new_missions');
$email->emailFormat('both');
$email->viewVars(['missions' => $missionsToSend]);
$email->send();
}
}
示例8: send
/**
* Send mail
*
* @param \Cake\Mailer\Email $email Email
* @return array
*/
public function send(Email $email)
{
if (!empty($this->_config['queue'])) {
$this->_config = $this->_config['queue'] + $this->_config;
$email->config((array) $this->_config['queue'] + ['queue' => []]);
unset($this->_config['queue']);
}
$settings = ['from' => [$email->from()], 'to' => [$email->to()], 'cc' => [$email->cc()], 'bcc' => [$email->bcc()], 'charset' => [$email->charset()], 'replyTo' => [$email->replyTo()], 'readReceipt' => [$email->readReceipt()], 'returnPath' => [$email->returnPath()], 'messageId' => [$email->messageId()], 'domain' => [$email->domain()], 'getHeaders' => [$email->getHeaders()], 'headerCharset' => [$email->headerCharset()], 'theme' => [$email->theme()], 'profile' => [$email->profile()], 'emailFormat' => [$email->emailFormat()], 'subject' => [$email->getOriginalSubject()], 'transport' => [$this->_config['transport']], 'attachments' => [$email->attachments()], 'template' => $email->template(), 'viewVars' => [$email->viewVars()]];
foreach ($settings as $setting => $value) {
if (array_key_exists(0, $value) && ($value[0] === null || $value[0] === [])) {
unset($settings[$setting]);
}
}
$QueuedTasks = TableRegistry::get('Queue.QueuedTasks');
$result = $QueuedTasks->createJob('Email', ['settings' => $settings]);
$result['headers'] = '';
$result['message'] = '';
return $result;
}
示例9: testrun
public function testrun()
{
$starttime = time();
$this->out('[' . date('Y-m-d H:i:s') . '] Creating Job ...');
// this creates a job (try different settings here for testing)
$email = new Email();
$email->template('CodeBlastrQueue.testeree', 'CodeBlastrQueue.testeroo')->to('sample@example.com')->subject('About Me')->emailFormat('both')->attachments(['cake.icon.png' => ['file' => ROOT . '/webroot/img/cake.icon.png', 'mimetype' => 'image/png', 'contentId' => 'my-unique-id']])->send();
$this->runworker();
$endtime = time();
$this->out('Test run finished.');
}
示例10: forgot
function forgot()
{
if ($this->request->is('post')) {
$useremail = $this->request->data['user_email'];
$check_user = $this->Users->find()->where(['user_email' => $this->request->data['user_email']]);
$data = $check_user->toArray();
if ($check_user->count() > 0) {
$alphabet = "ABCDEFGHIJKLMNPQRSTUWXYZ123456789!@#\$";
$pass = array();
$alphaLength = strlen($alphabet) - 1;
for ($i = 0; $i < 8; $i++) {
$n = rand(0, $alphaLength);
$pass[] = $alphabet[$n];
}
$user_pass = implode($pass);
$email = new Email();
$email->template('forgot')->emailFormat('html')->viewVars(['useremail' => $useremail, 'newpass' => $user_pass])->from(['noreply@ethoswatches.com' => 'Ethos Watches'])->to($useremail)->subject('New Password for Eforce account');
if ($email->send()) {
$user = $this->Users->get($data[0]->id);
$user->password = (new DefaultPasswordHasher())->hash($user_pass);
$this->Users->save($user);
$this->Flash->success(__('New password send on tour Email'));
} else {
$this->Flash->error('Please try Again');
}
} else {
//echo 'Email ID does not exists';
$this->Flash->error('Email ID does not exists');
//SessionComponent::setFlash('Email ID does not exists','flash_error');
}
}
//$url = $this->request->data['url'];
//$this->redirect(BASE_URL.$url);
}
示例11: register
/**
* Register method
*
* @return void Redirects on successful add, renders view otherwise.
* */
public function register()
{
$this->viewBuilder()->layout('registerv2');
$user = $this->Users->newEntity();
if ($this->request->is('post')) {
if ($this->Recaptcha->verify()) {
$user = $this->Users->patchEntity($user, $this->request->data);
$user->email_validation_code = rand(10000, 99999);
$user->role = 'student';
if ($this->Users->save($user)) {
$email = new Email();
$email->template('confirmation')->emailFormat('text')->to($user->email)->from('egresados@tectijuana.edu.mx');
$validate_url = "http://www.egresadositt.com/users/validateEmail/{$user->id}/{$user->email_validation_code}";
$email->viewVars(['first_name' => $user->first_name, 'email_validation_code' => $validate_url, 'user_name' => $user->username]);
$email->send();
$this->Flash->success(__('The user has been saved.'));
return $this->redirect(['controller' => 'Pages', 'action' => 'success']);
} else {
$this->Flash->error(__('The user could not be saved. Please, try again.'));
}
} else {
$this->Flash->error(__('Please check your Recaptcha Box.'));
}
}
$generations = $this->Users->Generations->find('list', ['limit' => 200]);
$careers = $this->Users->Careers->find('list', ['limit' => 200]);
$questions = $this->Users->Questions->find('list', ['limit' => 200]);
$this->set(compact('user', 'generations', 'careers', 'questions'));
$this->set('_serialize', ['user']);
}
示例12: requestPasswordReset
public function requestPasswordReset()
{
if ($this->request->is('post')) {
$user = $this->Users->findByEmail($this->request->data['email'])->first();
if (!empty($user)) {
$resetKey = Text::uuid();
$user = $this->Users->patchEntity($user, ['id' => $user->id, 'reset_key' => $resetKey, 'reset_timestamp' => new \DateTime()]);
if ($this->Users->save($user)) {
$email = new Email();
$email->template('reset', 'default')->emailFormat('html')->to($user->email)->subject('Password Reset Requested')->viewVars(['user' => $user])->send();
$this->Flash->success('An email has been sent to you with a link to reset your password.');
} else {
$this->Flash->error('An error occured when trying to reset your password, please try again.');
}
}
}
}
示例13: testRequestJob
public function testRequestJob()
{
$email = new Email();
$email->template('default', 'default')->to('sample@example.com')->subject('About Me')->send();
$this->assertTrue(!empty($this->Queues->requestJob()));
}
示例14: sendMail
/**
* For sending mail with specific infomation
*/
public function sendMail($ticketInfo)
{
$subject = 'OSM Ticket: ' . $ticketInfo['subject'];
$empEmail = ADMIN_EMAIL;
if (!empty($empEmail)) {
$email = new Email('default');
$email->template('raiseticket')->emailFormat('html')->to($empEmail)->subject($subject)->viewVars(['input' => $ticketInfo])->send();
}
}
示例15: send
/**
* Send message method.
*
* @param string $subject
* @param string $content
* @param string|array $to
* @param string $fromName
* @param string $fromEmail
* @return array
*/
public function send($subject, $content, $to, $fromName = '', $fromEmail = '')
{
$mail = new Mailer();
$fromName = !empty($fromName) ? $fromName : $this->_fromName;
$fromEmail = !empty($fromEmail) ? $fromEmail : $this->_fromEmail;
return $mail->template($this->_tpl)->emailFormat($this->_format)->from($fromEmail, $fromName)->to($to)->subject($subject)->send($content);
}