本文整理汇总了PHP中CakeEmail::from方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeEmail::from方法的具体用法?PHP CakeEmail::from怎么用?PHP CakeEmail::from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeEmail
的用法示例。
在下文中一共展示了CakeEmail::from方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Sends out email via Mandrill
*
* @param CakeEmail $email
* @return array
*/
public function send(CakeEmail $email)
{
// CakeEmail
$this->_cakeEmail = $email;
$from = $this->_cakeEmail->from();
list($fromEmail) = array_keys($from);
$fromName = $from[$fromEmail];
$this->_config = $this->_cakeEmail->config();
$this->_headers = $this->_cakeEmail->getHeaders();
$message = array('html' => $this->_cakeEmail->message('html'), 'text' => $this->_cakeEmail->message('text'), 'subject' => mb_decode_mimeheader($this->_cakeEmail->subject()), 'from_email' => $fromEmail, 'from_name' => $fromName, 'to' => array(), 'headers' => array('Reply-To' => $fromEmail), 'important' => false, 'track_opens' => null, 'track_clicks' => null, 'auto_text' => null, 'auto_html' => null, 'inline_css' => null, 'url_strip_qs' => null, 'preserve_recipients' => null, 'view_content_link' => null, 'tracking_domain' => null, 'signing_domain' => null, 'return_path_domain' => null, 'merge' => true, 'tags' => null, 'subaccount' => null);
$message = array_merge($message, $this->_headers);
foreach ($this->_cakeEmail->to() as $email => $name) {
$message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'to');
}
foreach ($this->_cakeEmail->cc() as $email => $name) {
$message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'cc');
}
foreach ($this->_cakeEmail->bcc() as $email => $name) {
$message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'bcc');
}
$attachments = $this->_cakeEmail->attachments();
if (!empty($attachments)) {
$message['attachments'] = array();
foreach ($attachments as $file => $data) {
$message['attachments'][] = array('type' => $data['mimetype'], 'name' => $file, 'content' => base64_encode(file_get_contents($data['file'])));
}
}
$params = array('message' => $message, "async" => false, "ip_pool" => null, "send_at" => null);
return $this->_exec($params);
}
示例2: handleException
public function handleException(Exception $exception, $shutdown = false)
{
$this->_exception = $exception;
$email = new CakeEmail('error');
$prefix = Configure::read('ExceptionNotifier.prefix');
$from = $email->from();
if (empty($from)) {
$email->from('exception.notifier@default.com', 'Exception Notifier');
}
$subject = $email->subject();
if (empty($subject)) {
$email->subject($prefix . '[' . date('Ymd H:i:s') . '][' . $this->_getSeverityAsString() . '][' . ExceptionText::getUrl() . '] ' . $exception->getMessage());
}
if ($this->useSmtp) {
$email->transport('Smtp');
$email->config($this->smtpParams);
}
$text = ExceptionText::getText($exception->getMessage(), $exception->getFile(), $exception->getLine());
$email->send($text);
// return Exception.handler
if ($shutdown || !$this->_exception instanceof ErrorException) {
$config = Configure::read('Exception');
$handler = $config['handler'];
if (is_string($handler)) {
call_user_func($handler, $exception);
} elseif (is_array($handler)) {
call_user_func_array($handler, $exception);
}
}
}
示例3: sendResetMail
/**
* sendResetMail
*
*/
public static function sendResetMail($data, $user)
{
$modelName = $data['model'];
$loader = ReminderConfigLoader::init($modelName);
$email = new CakeEmail('reminder');
$from = $email->from();
if (empty($from)) {
$email->from('reminder@example.com', 'Reminder');
}
$subject = $loader->load('subject');
if (empty($subject)) {
$subject = $email->subject();
}
if (empty($subject)) {
$subject = 'Reminder';
// default
}
$email->subject($subject);
$email->to($data['email']);
$template = $loader->load('view.reset_mail');
if (empty($template)) {
$template = 'reset_mail';
}
$email->template('Reminder.' . $template);
$email->viewVars(array('data' => $data, 'user' => $user));
return $email->send();
}
示例4: send
/**
* Sends out email via SparkPost
*
* @param CakeEmail $email
* @return array
*/
public function send(CakeEmail $email)
{
// CakeEmail
$this->_cakeEmail = $email;
$this->_config = $this->_cakeEmail->config();
$this->_headers = $this->_cakeEmail->getHeaders();
// Not allowed by SparkPost
unset($this->_headers['Content-Type']);
unset($this->_headers['Content-Transfer-Encoding']);
unset($this->_headers['MIME-Version']);
unset($this->_headers['X-Mailer']);
$from = $this->_cakeEmail->from();
list($fromEmail) = array_keys($from);
$fromName = $from[$fromEmail];
$message = ['html' => $this->_cakeEmail->message('html'), 'text' => $this->_cakeEmail->message('text'), 'from' => ['name' => $fromName, 'email' => $fromEmail], 'subject' => mb_decode_mimeheader($this->_cakeEmail->subject()), 'recipients' => [], 'transactional' => true];
foreach ($this->_cakeEmail->to() as $email => $name) {
$message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
}
foreach ($this->_cakeEmail->cc() as $email => $name) {
$message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
}
foreach ($this->_cakeEmail->bcc() as $email => $name) {
$message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
}
unset($this->_headers['tags']);
$attachments = $this->_cakeEmail->attachments();
if (!empty($attachments)) {
$message['attachments'] = array();
foreach ($attachments as $file => $data) {
if (!empty($data['contentId'])) {
$message['inlineImages'][] = array('type' => $data['mimetype'], 'name' => $data['contentId'], 'data' => base64_encode(file_get_contents($data['file'])));
} else {
$message['attachments'][] = array('type' => $data['mimetype'], 'name' => $file, 'data' => base64_encode(file_get_contents($data['file'])));
}
}
}
$message = array_merge($message, $this->_headers);
// Load SparkPost configuration settings
$config = ['key' => $this->_config['sparkpost']['api_key']];
if (isset($this->_config['sparkpost']['timeout'])) {
$config['timeout'] = $this->_config['sparkpost']['timeout'];
}
// Set up HTTP request adapter
$httpAdapter = new Ivory\HttpAdapter\Guzzle6HttpAdapter($this->__getClient());
// Create SparkPost API accessor
$sparkpost = new SparkPost\SparkPost($httpAdapter, $config);
// Send message
try {
return $sparkpost->transmission->send($message);
} catch (SparkPost\APIResponseException $e) {
// TODO: Determine if BRE is the best exception type
throw new BadRequestException(sprintf('SparkPost API error %d (%d): %s (%s)', $e->getAPICode(), $e->getCode(), ucfirst($e->getAPIMessage()), $e->getAPIDescription()));
}
}
示例5: _prepareData
/**
* Prepares the data array.
*
* @return void
*/
protected function _prepareData()
{
$headers = $this->_cakeEmail->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject'));
if ($headers['Sender'] == '') {
$headers['Sender'] = $headers['From'];
}
$headers = $this->_headersToString($headers);
$message = implode("\r\n", $this->_cakeEmail->message());
$this->_data = array('Data' => base64_encode($headers . "\r\n\r\n" . $message . "\r\n\r\n\r\n."));
$this->_dataOptions = array('Source' => key($this->_cakeEmail->from()), 'Destinations' => array());
$this->_dataOptions['Destinations'] += array_keys($this->_cakeEmail->to());
$this->_dataOptions['Destinations'] += array_keys($this->_cakeEmail->cc());
$this->_dataOptions['Destinations'] += array_keys($this->_cakeEmail->bcc());
$this->_content = array('headers' => $headers, 'message' => $message);
}
示例6: preview
public function preview($e)
{
$configName = $e['EmailQueue']['config'];
$template = $e['EmailQueue']['template'];
$layout = $e['EmailQueue']['layout'];
$headers = empty($e['EmailQueue']['headers']) ? array() : (array) $e['EmailQueue']['headers'];
$theme = empty($e['EmailQueue']['theme']) ? null : (string) $e['EmailQueue']['theme'];
if (empty($theme)) {
$theme = '';
}
$email = new CakeEmail($configName);
$email->transport('Debug')->to($e['EmailQueue']['to'])->subject($e['EmailQueue']['subject'])->template($template, $layout)->emailFormat($e['EmailQueue']['format'])->addHeaders($headers)->theme($theme)->messageId(false)->returnPath($email->from())->viewVars($e['EmailQueue']['template_vars']);
$return = $email->send();
$this->out('Content:');
$this->hr();
$this->out($return['message']);
$this->hr();
$this->out('Headers:');
$this->hr();
$this->out($return['headers']);
$this->hr();
$this->out('Data:');
$this->hr();
debug($e['EmailQueue']['template_vars']);
$this->hr();
$this->out();
}
示例7: forgot
/**
* permet de refaire un mot de passe oublié
* @return [type] [description]
**/
public function forgot()
{
$this->layout = "home";
if (!empty($this->request->data)) {
$user = $this->User->findByMail($this->request->data['User']['mail'], array('id'));
if (empty($user)) {
$this->Session->setFlash(__("This email address is not associated with any account"), 'notif', array('class' => "danger", 'type' => 'info'));
} else {
$token = md5(uniqid() . time());
$this->User->id = $user['User']['id'];
$this->User->saveField('token', $token);
App::uses('CakeEmail', 'Network/Email');
$cakeMail = new CakeEmail('smtp');
// à changer par default sur le site en ligne ou smtp en local
$cakeMail->to($this->request->data['User']['mail']);
$cakeMail->from(array('philippewagner2@sfr.fr' => "site "));
$cakeMail->subject(__('Password regeneration'));
$cakeMail->template('forgot');
$cakeMail->viewVars(array('token' => $token, 'id' => $user['User']['id']));
$cakeMail->emailFormat('text');
$cakeMail->send();
$this->Session->setFlash(__("An email was sent to you with instructions to regenerate your password! Please check your span !!"), "notif", array('class' => 'info', 'type' => 'info'));
}
}
}
示例8: index
public function index()
{
//checking session
$uid = $this->Session->read('Auth.User.id');
if (isset($uid)) {
return $this->redirect(array('controller' => 'profiles', 'action' => 'edit'));
}
$this->layout = 'main';
$title = 'User Registration';
$this->set(compact('title'));
//check from submit or not
if ($this->request->is('post')) {
//uploading image file
$new_file_name = rand(1000, rand(100000, rand(1000000, 10000000))) . "_" . md5(time()) . "_" . time() . $this->data['Profile']['image']['name'];
move_uploaded_file($this->data['Profile']['image']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/registration/app/webroot/img/image/' . $new_file_name);
$this->request->data['Profile']['image'] = '/registration/app/webroot/img/image/' . $new_file_name;
//----------------------
//save data
if ($this->Profile->save($this->request->data)) {
$Email = new CakeEmail();
$Email->from(array('me@example.com' => 'Cake registration demo'));
$Email->to($this->data['Profile']['email']);
$Email->subject('Registration process completed successfully');
$Email->send('Welcome to cake registration demo .Your registration process completed successfully');
$this->Session->setFlash('User details has been saved.', 'default', array('class' => 'alert alert-success'));
return $this->redirect(array('action' => 'login'));
}
//------------
//on failure
$this->Session->setFlash('Unable to add User details.', 'default', array('class' => 'alert alert-danger'));
}
}
示例9: send_mail
/**
* Send comfirmation email whit unique code
*/
public function send_mail()
{
$user = $this->Session->read('Auth');
if (isset($user)) {
if ($user['User']['active'] == 0) {
$uniqueId = uniqid("", TRUE);
if ($this->saveSendComfirmation($user, $uniqueId)) {
App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail('gmail');
$link = "http://" . $_SERVER['HTTP_HOST'] . $this->webroot . "email/activate_account/" . $user['User']['id'] . '-' . $uniqueId;
$email->from('stagesstatcoordonateur@gmail.com');
$email->to($user['User']['email']);
$email->subject('Mail Confirmation');
$email->emailFormat('html');
$email->template('signup');
$email->viewVars(array('username' => $user['User']['full_name'], 'link' => $link));
$this->Session->setFlash(__('Email comfirmation has been sent'), 'flash/success');
$email->send();
} else {
$this->Session->setFlash(__('Could not send email.'), 'flash/error');
}
} else {
$this->Session->setFlash(__('Your email is already comfirmed.'), 'flash/error');
}
} else {
$this->Session->setFlash(__('You are not login.'), 'flash/error');
}
$this->redirect('/');
}
示例10: index
/**
* index method
*
* @return void
*/
public function index()
{
$this->Comment->recursive = 0;
if (!empty($this->request->data)) {
$this->Comment->create($this->request->data);
if ($this->Comment->validates()) {
if (!empty($this->request->data['Comment']['website'])) {
$this->Session->setFlash(__("Your Mail us is reached."), 'notif', array('class' => "success", 'type' => 'ok-sign'));
$this->request->data = array();
} else {
$token = md5(time() . ' - ' . uniqid());
$this->Comment->create(array('name' => $this->request->data['Comment']['name'], 'mail' => $this->request->data['Comment']['mail'], 'content' => $this->request->data['Comment']['content'], 'token' => $token));
$this->Comment->save();
App::uses('CakeEmail', 'Network/Email');
$CakeEmail = new CakeEmail('smtp');
// à changer par Default sur le site en ligne sinon smtp
$CakeEmail->to(array('philippewagner2@sfr.fr'));
$CakeEmail->from(array($this->request->data['Comment']["mail"] => "livre d or"));
$CakeEmail->subject(__("Commentaire sur le livre d'or"));
$CakeEmail->viewVars($this->request->data['Comment'] + array("name" => $this->Comment->name, "mail" => $this->Comment->mail, "content" => $this->Comment->content, 'token' => $token, 'id' => $this->Comment->id));
$CakeEmail->emailFormat('html');
$CakeEmail->template('commentaire');
$CakeEmail->send();
$this->Session->setFlash(__('The comment has been saved.'), 'notif', array('class' => "success", 'type' => 'ok-sign'));
return $this->redirect(array('action' => 'index'));
}
} else {
$this->Session->setFlash(__('The comment could not be saved. Please, try again.'), 'notif', array('class' => "danger", 'type' => 'info-sign'));
}
}
$this->paginate = array('Comment' => array('limit' => 3, 'order' => array('Comment.created' => 'desc')));
$d['comments'] = $this->Paginate('Comment', array('Comment.online >= 1'));
$this->set($d);
}
示例11: __resetPassword
protected function __resetPassword($username = '')
{
$this->loadModel('User');
$conditions = array('username' => $username);
$options = array('conditions' => $conditions);
$user = $this->User->find('first', $options);
$message = 'El usuario no existe.';
if ($user) {
$data['password'] = $this->strongPassword($username);
$this->User->id = $user['User']['id'];
$mensaje = 'No ha sido posible cambiar el password, intente de nuevo.';
if ($this->User->save($data)) {
$email = new CakeEmail('default');
$email->template('change_password');
$email->emailFormat('text');
$email->from('mail@institucion.gob.sv');
$email->to($username);
$email->subject('Reinicio de credenciales gobscore.');
$email->viewVars(array('username' => $username, 'password' => $data['password']));
$message = 'El password ha sido cambiado con éxito. Ha ocurrido un ' . 'error en el envío de su nuevo password.';
if ($email->send()) {
$message = 'Los datos de la institución y cuenta de ' . 'administrador han sido enviados correctamente';
}
}
}
return $message;
}
示例12: add
/**
* add method
*
* @return void
*/
public function add()
{
$institucions = $this->User->Institucion->find('list');
if ($this->request->is('post')) {
// Password
$password = $this->strongPassword($this->request->data['User']['username']);
$this->request->data['User']['password'] = $password;
$this->request->data['User']['role'] = 'administrador';
$this->request->data['User']['active'] = true;
$this->User->create();
if ($this->User->save($this->request->data)) {
// Envio de clave al usuario
$email = new CakeEmail('default');
$email->template('administrador');
$email->emailFormat('text');
$email->from('mail@institucion.gob.sv');
$email->to($this->request->data['User']['username']);
$email->subject('Cuenta gobscore.');
$email->viewVars(array('name' => $this->request->data['User']['name'], 'institucion' => $institucions[$this->request->data['User']['institucion_id']], 'username' => $this->request->data['User']['username'], 'password' => $password));
if ($email->send()) {
$mensaje = 'Los datos de la institución y cuenta de ' . 'administrador han sido enviados correctamente';
}
$this->Session->setFlash($mensaje);
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('La información ha no sido almacenada. Por favor, trate de nuevo.'));
}
}
$this->set(compact('institucions'));
}
示例13: index
public function index()
{
if (!empty($this->data)) {
if ($this->request->is('post')) {
$data = $this->request->data;
if ($this->Matriculation->save($data)) {
$email = new CakeEmail();
$email->config('default');
$email->from(array('contato@sardonixidiomas.com' => 'Sardonix Idiomas | Automático'));
$email->to('contato@sardonixidiomas.com');
$email->subject("Matrícula - {$data['Matriculation']['name']} ");
$cursos = '';
if (isset($data['Matriculation']['english'])) {
$cursos .= 'Inglês; ';
}
if (isset($data['Matriculation']['italian'])) {
$cursos .= 'Italiano; ';
}
if (isset($data['Matriculation']['portuguese'])) {
$cursos .= 'Português; ';
}
$date = new DateTime();
$message = "Nome: {$data['Matriculation']['name']}\n\n";
$message .= "Telefone: {$data['Matriculation']['phone']}\n\n";
$message .= "Celular: {$data['Matriculation']['cellphone']}\n\n";
$message .= "Idiomas de interesse: {$cursos}\n\n";
$message .= "E-mail: {$data['Matriculation']['email']} \n\n";
$message .= "Soube: {$data['Matriculation']['where']}\n\n";
$message .= "Acessou em: " . $date->format('d/m/Y H:i:s');
$email->send($message);
$this->render('enviado');
}
}
}
}
示例14: contact
public function contact()
{
$this->loadModel('Contact');
if ($this->request->is('post')) {
$this->Contact->set($this->request->data);
if ($this->Contact->validates()) {
App::uses('CakeEmail', 'Network/Email');
if ($this->request->data['Contact']['subject'] == '') {
$this->request->data['Contact']['subject'] = 'Contact';
}
$Email = new CakeEmail('smtp');
$Email->viewVars(array('mailData' => $this->request->data));
$Email->template('contact', 'default');
$Email->emailFormat('html');
$Email->from(array($this->request->data['Contact']['mail'] => $this->request->data['Contact']['name']));
$Email->to('contact@youthbook.be');
$Email->subject($this->request->data['Contact']['subject']);
$Email->attachments(array('logo.png' => array('file' => WWW_ROOT . '/img/icons/logo.png', 'mimetype' => 'image/png', 'contentId' => 'logo')));
$Email->send();
$this->Flash->success(__('Votre mail a bien été envoyé.'));
return $this->redirect($this->referer());
} else {
$this->Session->write('errors.Contact', $this->Contact->validationErrors);
$this->Session->write('data', $this->request->data);
$this->Session->write('flash', 'Le mail n’a pas pu être envoyé. Veuillez réessayer SVP.');
return $this->redirect($this->referer());
}
}
}
示例15: RecoverPassword
function RecoverPassword($username)
{
$response = array('status' => false, 'message' => 'Ocurrió un error');
$this->Behaviors->attach('Containable');
if ($user = $this->find('first', array('conditions' => array('UsuarioInterno.username' => $username), 'contain' => array('Empresa')))) {
$this->id = $user['UsuarioInterno']['id'];
$token = md5($user['UsuarioInterno']['id'] . $user['UsuarioInterno']['username'] . date('d-m-Y'));
if ($this->saveField('token', $token)) {
App::uses('CakeEmail', 'Network/Email');
$url = Router::url(array('controller' => 'empresas', 'action' => 'cambiar_clave', $token), true);
$Email = new CakeEmail();
$Email->template('password');
$Email->from(array('noreply@xperiencialaboral.com' => 'Xperiencia Laboral'));
$Email->to($user['UsuarioInterno']['email']);
$Email->subject('Recuperacion contraseña Xperiencia Laboral');
$Email->viewVars(array('nombre' => $user['UsuarioInterno']['nombre'] . ' ' . $user['UsuarioInterno']['apellido'], 'url' => $url));
$Email->emailFormat('html');
if ($Email->send()) {
$response['message'] = 'Un link para reestablecer tu contraseña ha sido enviado a tu email ' . $user['UsuarioInterno']['email'];
$response['status'] = true;
} else {
$response['message'] = 'Ocurrio un error al intentar enviar el mail';
}
}
} else {
$response['message'] = 'El email ingresado no corresponde a un usuario existente';
}
return $response;
}