本文整理汇总了PHP中CakeEmail类的典型用法代码示例。如果您正苦于以下问题:PHP CakeEmail类的具体用法?PHP CakeEmail怎么用?PHP CakeEmail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CakeEmail类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: contact
public function contact()
{
$this->setTitle('Liên hệ');
if ($this->request->is('post')) {
$this->loadModel('Contact');
$save_data = array('Contact' => array('name' => $this->request->data('name'), 'address' => $this->request->data('address'), 'phone' => $this->request->data('phone'), 'email' => $this->request->data('email'), 'title' => 'Liên hệ : ' . $this->request->data('name'), 'descriptions' => $this->request->data('message')));
if ($this->Contact->save($save_data)) {
$Email = new CakeEmail('smtp');
$Email->emailFormat('text')->subject($save_data['Contact']['title']);
$this->loadModel('Setting');
$mail_lists = $this->Setting->getCacheSetting('mail_receiver');
$mail_lists = explode(';', $mail_lists['emails']['value']);
$mail_lists = array_filter($mail_lists);
// $mail_lists = Configure::read('mail_receiver');
if ($mail_lists) {
$Email->to($mail_lists);
$content = "\nNgười gửi : {$save_data['Contact']['name']} \n\nSố điện thoại : {$save_data['Contact']['phone']} \n\nEmail : {$save_data['Contact']['email']} \n\nĐịa chỉ : {$save_data['Contact']['address']} \n\nNội dung liên hệ : {$save_data['Contact']['descriptions']}\n\n\n\n ";
$Email->send($content);
}
echo json_encode(array('status' => 'ok', 'messages' => array('Cảm ơn bạn đã quan tâm đến BIOWAY-HITECH <br>Chúng tôi sẽ liên lạc lại bạn trong thời gian sớm nhất')));
die;
} else {
echo 'ng';
die;
}
}
}
示例2: send
/**
* Send mail
*
* @param CakeEmail $email CakeEmail
* @return array
*/
public function send(CakeEmail $email)
{
$headers = $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject'));
$headers = $this->_headersToString($headers);
$message = implode("\r\n", (array) $email->message());
return array('headers' => $headers, 'message' => $message);
}
示例3: sendPassword
public function sendPassword($emailLog)
{
$searchPlayer = "Select email From players As Player Where email = '";
$searchPlayer .= $emailLog;
$searchPlayer .= "'";
if (!$this->query($searchPlayer)) {
return false;
} else {
/*
* renvoie un pass chiffré. PAS BON !!
* renvoyer un mot de pass par défault
* rediriger vers la page change password
* faire comme si on changeait le mdp
*/
$tempPass = $this->generatePassword();
$tempPassCrypted = Security::hash($tempPass);
$updatePass = "Update players Set password = '" . $tempPassCrypted . "' Where email = '" . $emailLog . "'";
$this->query($updatePass);
//@todo: sauvegarder dans la base
$message = "Voici votre mot de passe temporaire. Connectez-vous avec pour le changer.";
App::uses('CakeEmail', 'Network/Email');
$mail = new CakeEmail('rox');
$mail->to($emailLog)->subject('WebArena Information')->template('player')->viewVars(array('message' => $message, 'email' => $emailLog, 'password' => $tempPass))->emailFormat('html');
return $mail->send();
}
}
示例4: register
/**
* Выдает информацию о пользователе
*
* @param array $data
* @return array
*/
public function register($data)
{
if ($data['full_name']) {
if (isset($data['surname']) and $data['surname']) {
$data['full_name'] = $data['full_name'] . ' ' . $data['surname'];
}
} else {
list($userName) = explode('@', $data['username']);
$data['full_name'] = $userName;
}
unset($data['surname']);
$this->User->set($data);
if (!$this->User->validates()) {
throw new ApiIncorrectRequestException($this->User->validationErrors);
}
if (!in_array($data['lang'], array('eng', 'rus'))) {
$errors = array('lang' => array('Incorrect Lang'));
throw new ApiIncorrectRequestException($errors);
}
if ($this->User->save($data)) {
$user = $this->User->findByUsername($data['username']);
$userId = Hash::get($user, 'User.id');
$userName = Hash::get($user, 'User.full_name');
$userMail = Hash::get($user, 'User.username');
$pass = substr($user['User']['password'], 0, 5);
$pass = md5('iP5UxZWIbVJ1XJIW' . $pass);
$Email = new CakeEmail();
$Email->template('reg_confirm', 'mail')->viewVars(array('userId' => $userId, 'userName' => $userName, 'userMail' => $userMail, 'token' => $pass))->emailFormat('html')->from('support@konstruktor.com')->to($data['username'])->subject('Verify registration on Konstruktor.com')->send();
return $userId;
} else {
throw new Exception('Registration Error');
}
}
示例5: sendEmail
/**
* メール送信処理
*/
public function sendEmail($to, $subject, $template, $body = null)
{
// メールライブラリ読み込み
App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail();
$res = $email->config(array('log' => 'emails'))->template($template, 'default')->viewVars($body)->from(array('support3@hiropro.co.jp' => __('iPost Enterprise運営事務局')))->to($to)->subject($subject)->send();
}
示例6: send
public function send() {
ini_set('max_execution_time', 0);
$test = array(
array('User' => array('email' =>'manhquan@5stars.vn'))
);
$this->User->unbindAll();
$users = $this->User->find('all', array('fields' => array('email'), 'conditions' => array('email not like "%@facebook.com%"'), 'order' => array('id DESC')));
$count = 1;
foreach ($users as $user) {
if (!empty($user['User']['email'])) {
$count++;
try {
$email = new CakeEmail('stars');
$email->template('open')
->emailFormat('html')
->from(array('info@5stars.vn' => '5Stars MobileGames Ltd'))
->to($user['User']['email'])
//->bcc(array('manhquan@5stars.vn'))
->subject('Mỹ Hầu Vương | Tri ân người chơi tặng Gift code 500k nhân ngày Openbeta')
->send();
echo $count.' sent to '.$user['User']['email'].' waiting 10 sec...'. "\n";
sleep(1);
} catch(Exception $e) {
echo $e->getMessage();
echo $count.'cannot send to '.$user['User']['email']. "\n";
}
}
}
}
示例7: 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'));
}
}
示例8: send
public function send()
{
if ($this->request->is('post')) {
// Check security token
if (empty($this->request->data['Feedback']['token']) || $this->request->data['Feedback']['token'] != '!pilule$') {
throw new NotFoundException();
}
// Send feedback via email
$Email = new CakeEmail();
if (!empty($this->request->data['Feedback']['name']) && !empty($this->request->data['Feedback']['email'])) {
$Email->replyTo(array($this->request->data['Feedback']['email'] => $this->request->data['Feedback']['name']));
}
$Email->from('web@alexandreclement.com');
$Email->to('web@alexandreclement.com');
$Email->config('postmark');
$Email->subject('Pilule - Commentaires');
$Email->template('feedback');
$Email->emailFormat('html');
$Email->viewVars(array('message' => $this->request->data));
if ($Email->send()) {
return new CakeResponse(array('body' => json_encode(array('status' => true))));
} else {
return new CakeResponse(array('body' => json_encode(array('status' => false))));
}
} elseif ($this->request->is('ajax')) {
$this->layout = 'ajax';
$this->render('modals/form');
}
}
示例9: forget
public function forget()
{
if ($this->request->is('post')) {
$error = null;
$email = $this->request->data['User']['email'];
$result = $this->User->find('first', array('conditions' => array('User.email' => $email)));
if ($result == null || empty($result)) {
$error = "メールアドレスが登録されていません。";
} else {
$host = empty($_SERVER['CAKE_ENV']) ? 'localhost' : $_SERVER['CAKE_ENV'];
$pre_id = $result['User']['pre_id'];
$gmail = new CakeEmail('gmail');
$gmail->to($email);
$gmail->subject('seapaパスワード再設定URL');
$messages = $gmail->send('パスワード再設定URL : http://' . $host . '/regist/reinput?pre_id=' . $pre_id);
if ($messages == null) {
$error = "メールが送信できませんでした。管理者にお問い合わせください。";
}
}
if (empty($error)) {
$this->redirect(array('controller' => 'preregist', 'action' => 'result'));
} else {
$this->Session->setFlash($error, "flash_error");
}
}
}
示例10: sendEmail
protected function sendEmail($address, $username, $pass)
{
$subject = 'You now are an user of Employees Directory!';
$body = 'Your username : ' . $username . '. Your password : ' . $pass . '. (not include the last period)';
$email = new CakeEmail('smtp');
$email->to($address)->subject($subject)->send($body);
}
示例11: run
/**
* Find a potential queue and if found, send each email one by one
*
* @return void
*/
public function run()
{
// The consumer ID will be placed against all pending emails
$consumerId = uniqid();
// Inform the user of the consumer id before proceeding
$this->_renderHeader();
$this->out(" Consumer ID: {$consumerId}", 2);
// Search for pending emails and apply the consumer id to them
if (!$this->EmailQueue->updatePending($consumerId)) {
return $this->out(' Found 0 items in queue, exiting ...', 2);
}
// Find all the emails which were assigned with the consumer id
$pendingItems = $this->EmailQueue->pendingItems($consumerId);
$this->out(' Found ' . count($pendingItems) . ' items in queue, dispatching:', 2);
// Loop through each email one by one
foreach ($pendingItems as $item) {
// Inform the user which email is being processed currency
$this->out(' ' . str_pad("# {$item['EmailQueue']['id']}", 7, ' ') . ' ' . str_pad($item['EmailQueue']['to'] . ' ', 40, '.'), false);
// Use your preferred email config here
$email = new CakeEmail('custom');
// Attempt to send the serialized email using the above config, log the status
if ($email->transportClass()->send(unserialize($item['EmailQueue']['serialized']))) {
$status = 1;
$this->out(' [<success> OK </success>]', 2);
} else {
$status = 2;
$this->out(' [<warning> !! </warning>]', 2);
}
// Attempt to update the email queue record with the new status
if (!$this->EmailQueue->saveItemStatus($item['EmailQueue']['id'], $status)) {
throw new Exception("Saving queue item failed, orphan created for ID #{$item['EmailQueue']['id']}!");
}
}
}
示例12: individualMail
public function individualMail($section, $arr = array())
{
$this->autoRender = false;
$contents = $this->Mail->findBySection($section);
$content = $contents['Mail']['content'];
foreach ($arr as $key => $val) {
$content = str_replace("~~{$key}~~", $val, $content);
}
if (!empty($arr['TO_EMAIL']) && Validation::email($arr['TO_EMAIL'], true)) {
$email = new CakeEmail();
$email->template('default');
$email->config('default');
$email->emailFormat('html')->to($arr['TO_EMAIL'])->subject($contents['Mail']['subject']);
try {
if ($email->send($content)) {
return;
} else {
return;
}
} catch (Exception $e) {
return;
}
}
return;
}
示例13: _sendEmail
protected function _sendEmail()
{
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail();
$Email->emailFormat('text')->template('new_user', 'default')->from(Configure::read('Site.email_from'))->replyTo($this->request->data['Contact']['email'])->subject('EU-GENIE Contact Form')->to(Configure::read('Site.email_to'));
$Email->send();
}
示例14: contactus
public function contactus()
{
if ($this->request->data) {
$this->request->data['Contact'] = Sanitize::clean($this->request->data, array("remove_html" => TRUE));
$cakeEmail = new CakeEmail('default');
if ($this->request->data['Contact']['emailbool'] == "2") {
$email_to = Configure::read('Config.general');
$cakeEmail->template('enquiry', 'default')->emailFormat('html')->to($email_to)->subject('HaRiMau - General Enquiry');
} else {
$email_to = Configure::read('Config.business');
$cakeEmail->template('enquiry', 'default')->emailFormat('html')->to($email_to)->subject('HaRiMau - Business Enquiry');
}
$cakeEmail->viewVars(array('user' => $this->request->data));
if ($cakeEmail->send()) {
$cnt_data = $this->Notification->find('count', array('conditions' => array('markas' => 'Unread', 'type' => 'Contact')));
$arr['Notification']['type'] = 'Contact';
$arr['Notification']['status'] = 'Approve';
$arr['Notification']['count'] = $cnt_data + 1;
$arr['Notification']['markas'] = 'Unread';
$arr['Notification']['bell'] = 'On';
$noti = $this->Notification->save($arr);
$noti_data = $this->Notification->find('all', array('conditions' => array('markas' => 'Unread')));
$numNoti = count($noti_data);
$this->set('count', $numNoti);
$this->Session->setFlash('<div class="alert alert-success"><i class="fa fa-check-circle"></i> An email with details is sent to system admin as earliest as will replied you. <button data-dismiss="alert" class="close" type="button">×</button> </div>');
//$this->Session->setFlash(__('An email with details is sent to system admin as earliest as will replied you. '));
} else {
$this->Session->setFlash('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> Problem on sending email to enquiry department. Please contact to administrator.<button data-dismiss="alert" class="close" type="button">×</button> </div>');
//$this->Session->setFlash(__('Problem on sending email to enquiry department. Please contact to administrator'));
}
} else {
$this->set('count', 0);
}
}
示例15: 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();
}