本文整理汇总了PHP中Cake\Mailer\Email::profile方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::profile方法的具体用法?PHP Email::profile怎么用?PHP Email::profile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Mailer\Email
的用法示例。
在下文中一共展示了Email::profile方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send email via Mailgun SDK
*
* @param Email $email
* @return \stdClass $result containing status code and message
* @throws Exception
*/
public function send(Email $email)
{
$config = $email->profile();
$email->domain($config['mailgun_domain']);
$emailHeaders = ['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject', '_headers'];
//'_headers' will include all extra tags that may be related to mailgun fields with prefix 'o:' or custom data with prefix 'v:'
foreach ($email->getHeaders($emailHeaders) as $header => $value) {
if (isset($this->ParamMapping[$header]) && !empty($value)) {
//empty params are not excepted by mailgun, throws error
$key = $this->ParamMapping[$header];
$params[$key] = $value;
continue;
}
if ($this->isDataCustom($header, $value)) {
$params[$header] = $value;
}
}
$params['html'] = $email->message(Email::MESSAGE_HTML);
$params['text'] = $email->message(Email::MESSAGE_TEXT);
$attachments = array();
foreach ($email->attachments() as $name => $file) {
$attachments['attachment'][] = ['filePath' => '@' . $file['file'], 'remoteName' => $name];
}
return $this->mailgun($config, $params, $attachments);
}
示例2: email
/**
* Creates an email instance overriding its transport for testing purposes.
*
* @param bool $new Tells if new instance should forcebly be created.
* @return \Cake\Mailer\Email
*/
public function email($new = false)
{
if ($new || !$this->_email) {
$this->_email = new Email();
$this->_email->profile(['transport' => 'debug'] + $this->_email->profile());
}
return $this->_email;
}
示例3: _execute
protected function _execute(array $data)
{
$email = new Email();
$email->profile('default');
$email->from([$data['email']])->to('ken.kitchen@gmail.com')->subject('Web Site Contact Form')->send([$data['body']]);
return true;
}
示例4: send
public function send($to, $variables = [], $options = [])
{
$result = false;
if (!isset($options['transport'])) {
$options['transport'] = $this->config('transport');
}
if (!isset($options['emailFormat'])) {
$options['emailFormat'] = $this->config('emailFormat');
}
if (Configure::read('Email.queue')) {
if (isset($options['from'])) {
$options['from_name'] = reset($options['from']);
$options['from_email'] = key($options['from']);
unset($options['from']);
}
EmailQueue::enqueue($to, $variables, $options);
$result = true;
} else {
$options['to'] = $to;
$options['viewVars'] = $variables;
$email = new Email();
$email->profile($options);
$result = $email->send();
}
return $result;
}
示例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: 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' => method_exists($email, 'getOriginalSubject') ? [$email->getOriginalSubject()] : [$email->subject()], '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]);
}
}
$QueuedJobs = $this->getQueuedJobsModel();
$result = $QueuedJobs->createJob('Email', ['settings' => $settings]);
$result['headers'] = '';
$result['message'] = '';
return $result;
}
示例7: send
/**
* Send notification
*
* @param \CvoTechnologies\Notifier\Notification $notification Notification instance.
* @return array
*/
public function send(Notification $notification)
{
$email = new Email();
$email->profile($this->config('profile'));
$email->to($notification->to(null, static::TYPE));
$email->subject($notification->title());
$email->viewBuilder()->templatePath($notification->viewBuilder()->templatePath());
$email->viewBuilder()->template($notification->viewBuilder()->template());
$email->viewBuilder()->plugin($notification->viewBuilder()->plugin());
$email->viewBuilder()->theme($notification->viewBuilder()->theme());
$email->viewBuilder()->layout($notification->viewBuilder()->layout());
$email->viewBuilder()->autoLayout($notification->viewBuilder()->autoLayout());
$email->viewBuilder()->layoutPath($notification->viewBuilder()->layoutPath());
$email->viewBuilder()->name($notification->viewBuilder()->name());
$email->viewBuilder()->className($notification->viewBuilder()->className());
$email->viewBuilder()->options($notification->viewBuilder()->options());
$email->viewBuilder()->helpers($notification->viewBuilder()->helpers());
$email->viewVars($notification->viewVars());
return $email->send();
}
示例8: forgot_password
/**
* Mot de passe oublié.
*/
public function forgot_password()
{
if ($this->Auth->user()) {
$this->Flash->error(__('Vous êtes déjà connecté'));
return $this->redirect(['action' => 'profile']);
}
$user = $this->Users->newEntity($this->request->data);
if ($this->request->is('post')) {
$user = $this->Users->find()->where(['Users.mail' => $this->request->data['email']])->first();
if (is_null($user)) {
$this->Flash->error(__('Ce code est incorrect.'));
$this->redirect(['controller' => 'pages', 'action' => 'home']);
}
$code = md5(rand() . uniqid());
$user->password_code = $code;
$user->password_code_expire = new Time();
$this->Users->save($user);
$viewVars = ['userID' => $user->id, 'name' => $user->username, 'code' => $code];
$email = new Email();
$email->profile('default')->template('forgotPassword', 'default')->emailFormat('html')->from(['contact@oranticket.fr' => 'Mot de passe oublié'])->subject(__('[OranTicket] Mot de passe oublié'))->to($user->mail)->viewVars($viewVars)->send();
$this->Flash->success('Votre email à bien était envoyer.');
}
$this->set(compact('user'));
}
示例9: testProfileInvalid
/**
* Test that using an invalid profile fails.
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Unknown email configuration "derp".
*/
public function testProfileInvalid()
{
$email = new Email();
$email->profile('derp');
}
示例10: add
/**
* Ajout d'un ticket.
*/
public function add()
{
$user = $this->Auth->user();
$ticket = $this->Tickets->newEntity();
if ($this->request->is('post')) {
//if ($this->Recaptcha->verify()) {
$ticket = $this->Tickets->patchEntity($ticket, $this->request->data);
$ticket->public = $this->request->data(['public']);
$ticket->user_id = $user['id'];
// Je passe mes variables à mon template mail
$viewVars = ['subject' => $ticket->subjects, 'content' => nl2br($ticket->content)];
// SAUVEGARDE TICKET
if ($this->Tickets->save($ticket)) {
$email = new Email();
if ($this->request->data(['mail']) == true) {
$email->profile('default')->template('ticket', 'default')->emailFormat('html')->from(['contact@oranticket.fr' => 'Copie Ticket'])->subject(__('[OranTicket] Copie Ticket'))->to($user->mail)->viewVars($viewVars)->send();
}
$this->Flash->success(__('Votre ticket à bien était sauvegarder.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('Votre ticket n\'a pas plus être sauvegarder, veuillez recommencer.'));
}
//} else {
// $this->Flash->error('Veuillez valider le Recaptcha');
//}
}
$this->set('ticket', $ticket);
$this->set('_serialize', ['ticket']);
}
示例11: add
/**
* Ajout d'un ticket
*/
public function add()
{
$user = $this->Auth->user();
$ticket = $this->Tickets->newEntity();
if ($this->request->is('post')) {
if ($this->Recaptcha->verify() || Configure::read('site.debug') == false) {
$ticket = $this->Tickets->patchEntity($ticket, $this->request->data);
$ticket->public = $this->request->data(['public']);
$ticket->user_id = $user['id'];
// Je passe mes variables à mon template mail
$viewVars = ['subject' => $ticket->subjects, 'content' => nl2br($ticket->content)];
// Ajout d'un ticket
if ($this->Tickets->save($ticket)) {
$email = new Email();
if ($this->request->data(['mail']) == true) {
// Recevoir une copie du ticket par mail.
$email->profile('default')->template('ticket', 'default')->emailFormat('html')->from(['contact@Ticki.fr' => 'Copie Ticket'])->subject(__('[Ticki] Copie Ticket'))->to($user->mail)->viewVars($viewVars)->send();
}
$this->Flash->success(__('Votre ticket à bien était ajouté.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('Votre ticket n\'a pas plus être ajouté, veuillez recommencer.'));
}
} else {
$this->Flash->error('Veuillez valider le Recaptcha');
}
}
$this->set(compact('ticket'));
$this->set('_serialize', ['ticket']);
}