本文整理汇总了PHP中Cake\Network\Email\Email::profile方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::profile方法的具体用法?PHP Email::profile怎么用?PHP Email::profile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Network\Email\Email
的用法示例。
在下文中一共展示了Email::profile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send mail using Mandrill (by MailChimp)
*
* @param \Cake\Network\Email\Email $email Cake Email
* @return array
*/
public function send(Email $email)
{
$this->transportConfig = Hash::merge($this->transportConfig, $this->_config);
// Initiate a new Mandrill Message parameter array
$message = ['html' => $email->message(\Cake\Network\Email\Email::MESSAGE_HTML), 'text' => $email->message(\Cake\Network\Email\Email::MESSAGE_TEXT), 'subject' => $this->_decode($email->subject()), 'from_email' => key($email->from()), 'from_name' => current($email->from()), 'to' => [], 'headers' => ['Reply-To' => is_null(key($email->replyTo())) ? key($email->from()) : key($email->replyTo())], 'recipient_metadata' => [], 'attachments' => [], 'images' => []];
// Merge Mandrill Parameters
$message = array_merge($message, Hash::merge($this->defaultParameters, $email->profile()['Mandrill']));
// Add receipients
foreach (['to', 'cc', 'bcc'] as $type) {
foreach ($email->{$type}() as $mail => $name) {
$message['to'][] = ['email' => $mail, 'name' => $name, 'type' => $type];
}
}
// Attachments
$message = $this->_attachments($email, $message);
// Create a new scoped Http Client
$this->http = new Client(['host' => 'mandrillapp.com', 'scheme' => 'https', 'headers' => ['User-Agent' => 'CakePHP Mandrill Plugin']]);
// Sending as a template? Then in case we find mail content, we add this as a 'template_content'.
// In you Mandrill template, use <div mc:edit="content"></div> to get the contents of your email
if (!is_null($message['template_name']) && $message['html']) {
if (!isset($message['template_content']) || !is_array($message['template_content'])) {
$message['template_content'] = [];
}
$message['template_content'][] = ['name' => 'content', 'content' => $message['html']];
}
// Are we sending a template?
if (!is_null($message['template_name']) && !empty($message['template_content'])) {
return $this->_sendTemplate($message, $this->transportConfig['async'], $this->transportConfig['ip_pool'], $message['send_at']);
} else {
return $this->_send($message, $this->transportConfig['async'], $this->transportConfig['ip_pool'], $message['send_at']);
}
}
示例2: index
/**
* Contact page.
*
* @return \Cake\Network\Response|void
*/
public function index()
{
$contact = ['schema' => ['name' => ['type' => 'string', 'length' => 100], 'email' => ['type' => 'string', 'length' => 100], 'subject' => ['type' => 'string', 'length' => 255], 'message' => ['type' => 'string']], 'required' => ['name' => 1, 'email' => 1, 'message' => 1]];
if ($this->request->is('post')) {
$validator = new Validator();
$validator->notEmpty('email', __('You need to put your E-mail.'))->add('email', 'validFormat', ['rule' => 'email', 'message' => __("You must specify a valid E-mail address.")])->notEmpty('name', __('You need to put your name.'))->notEmpty('message', __("You need to give a message."))->add('message', 'minLength', ['rule' => ['minLength', 10], 'message' => __("Your message can not contain less than {0} characters.", 10)]);
$contact['errors'] = $validator->errors($this->request->data());
if (empty($contact['errors'])) {
$viewVars = ['ip' => $this->request->clientIp()];
$viewVars = array_merge($this->request->data(), $viewVars);
$email = new Email();
$email->profile('default')->template('contact')->emailFormat('html')->from(['contact@xeta.io' => 'Contact Form'])->to(Configure::read('Author.email'))->subject($viewVars['subject'] ? $viewVars['subject'] : 'Someone has contacted you')->viewVars($viewVars)->send();
$this->Flash->success(__("Your message has been sent successfully, you will get a response shortly !"));
return $this->redirect('/');
}
}
$this->set(compact('contact'));
}
示例3: testProfileInvalid
/**
* Test that using an invalid profile fails.
*
* @expectedException InvalidArgumentException
* @expectedExceptionMessage Unknown email configuration "derp".
*/
public function testProfileInvalid()
{
$email = new Email();
$email->profile('derp');
}
示例4: forgotPassword
/**
* Display the form to reset the password.
*
* @return \Cake\Network\Response|void
*/
public function forgotPassword()
{
if ($this->Auth->user()) {
return $this->redirect(['controller' => 'pages', 'action' => 'home']);
}
$user = $this->Users->newEntity($this->request->data);
if ($this->request->is('post')) {
$user = $this->Users->find()->where(['Users.email' => $this->request->data['email']])->first();
if (is_null($user)) {
$this->Flash->error(__("This E-mail doesn't exist or the account has been deleted."));
$this->set(compact('user'));
return;
}
if (!$this->Recaptcha->verify()) {
$this->Flash->error(__("Please, correct your Captcha."));
$this->set(compact('user'));
return;
}
//Generate the unique code
$code = md5(rand() . uniqid() . time());
//Update the user's information
$user->password_code = $code;
$user->password_code_expire = new Time();
$this->Users->save($user);
$viewVars = ['userId' => $user->id, 'name' => $user->full_name, 'username' => $user->username, 'code' => $code];
$email = new Email();
$email->profile('default')->template('forgotPassword', 'default')->emailFormat('html')->from(['no-reply@xeta.io' => __('Forgot your Password - Xeta')])->to($user->email)->subject(__('Forgot your Password - Xeta'))->viewVars($viewVars)->send();
$this->Flash->success(__("An E-mail has been send to <strong>{0}</strong>. Please follow the instructions in the E-mail.", h($user->email)));
}
$this->set(compact('user'));
}