/** * Form action handler for ContactInquiryForm. * * @param array $data The form request data submitted * @param Form $form The {@link Form} this was submitted on */ function dosave(array $data, Form $form, SS_HTTPRequest $request) { $SQLData = Convert::raw2sql($data); $attrs = $form->getAttributes(); if ($SQLData['Comment'] != '' || $SQLData['Url'] != '') { // most probably spam - terminate silently Director::redirect(Director::baseURL() . $this->URLSegment . "/success"); return; } $item = new ContactInquiry(); $form->saveInto($item); // $form->sessionMessage(_t("ContactPage.FORMMESSAGEGOOD", "Your inquiry has been submitted. Thanks!"), 'good'); $item->write(); $mailFrom = $this->currController->MailFrom ? $this->currController->MailFrom : $SQLData['Email']; $mailTo = $this->currController->MailTo ? $this->currController->MailTo : Email::getAdminEmail(); $mailSubject = $this->currController->MailSubject ? $this->currController->MailSubject . ' - ' . $SQLData['Ref'] : _t('ContactPage.SUBJECT', '[web] New contact inquiry - ') . ' ' . $data['Ref']; $email = new Email($mailFrom, $mailTo, $mailSubject); $email->replyTo($SQLData['Email']); $email->setTemplate("ContactInquiry"); $email->populateTemplate($SQLData); $email->send(); // $this->controller->redirectBack(); if ($email->send()) { $this->controller->redirect($this->controller->Link() . "success"); } else { $this->controller->redirect($this->controller->Link() . "error"); } return false; }
/** * Send the email * * @return void */ public function send() { if ($this->enabled) { if (!$this->emailer->send()) { $this->logger->addWarning($this->emailer->error()); } } else { $this->logger->addWarning('Faked sending an email ' . $this->emailer->get('body')); } }
public function action_email() { if (count($this->request->post())) { $hostname = $this->request->post('email_hostname'); $port = $this->request->post('email_port'); $username = $this->request->post('email_username'); $password = $this->request->post('email_password'); $encryption = $this->request->post('email_encryption'); $email_address = $this->request->post('email_address'); try { $config = $this->_create_email_config($hostname, $port, $username, $password, $encryption); // email_address if (strlen($email_address)) { try { Email::connect($config); Email::send($email_address, $email_address, "Beans Email Verification", "You can ignore this email - it was a self-generated message " . "used to verify your email server credentials.", FALSE); } catch (Exception $e) { return $this->_view->send_error_message("An error occurred when verifying your email settings: " . $e->getMessage()); } } Session::instance('native')->set('config_email', $config); $this->request->redirect('/install/auth'); } catch (Exception $e) { $this->_view->send_error_message($e->getMessage()); } } }
public function changeStatus() { $status = (int) $this->request->get('status'); $shipment = Shipment::getInstanceByID('Shipment', (int) $this->request->get('id'), true, array('Order' => 'CustomerOrder', 'ShippingAddress' => 'UserAddress')); $shipment->loadItems(); $zone = $shipment->getDeliveryZone(); $shipmentRates = $zone->getShippingRates($shipment); $shipment->setAvailableRates($shipmentRates); $history = new OrderHistory($shipment->order->get(), $this->user); $shipment->status->set($status); $shipment->save(); $history->saveLog(); $status = $shipment->status->get(); $enabledStatuses = $this->config->get('EMAIL_STATUS_UPDATE_STATUSES'); $m = array('EMAIL_STATUS_UPDATE_NEW' => Shipment::STATUS_NEW, 'EMAIL_STATUS_UPDATE_PROCESSING' => Shipment::STATUS_PROCESSING, 'EMAIL_STATUS_UPDATE_AWAITING_SHIPMENT' => Shipment::STATUS_AWAITING, 'EMAIL_STATUS_UPDATE_SHIPPED' => Shipment::STATUS_SHIPPED); $sendEmail = false; foreach ($m as $configKey => $constValue) { if ($status == $constValue && array_key_exists($configKey, $enabledStatuses)) { $sendEmail = true; } } if ($sendEmail || $this->config->get('EMAIL_STATUS_UPDATE')) { $user = $shipment->order->get()->user->get(); $user->load(); $email = new Email($this->application); $email->setUser($user); $email->setTemplate('order.status'); $email->set('order', $shipment->order->get()->toArray(array('payments' => true))); $email->set('shipments', array($shipment->toArray())); $email->send(); } return new JSONResponse(false, 'success'); }
/** * This does not actually perform any validation, but just creates the * initial registration object. */ public function validateStep($data, $form) { $form = $this->getForm(); $datetime = $form->getController()->getDateTime(); $confirmation = $datetime->Event()->RegEmailConfirm; $registration = $this->getForm()->getSession()->getRegistration(); // If we require email validation for free registrations, then send // out the email and mark the registration. Otherwise immediately // mark it as valid. if ($confirmation) { $email = new Email(); $config = SiteConfig::current_site_config(); $registration->TimeID = $datetime->ID; $registration->Status = 'Unconfirmed'; $registration->write(); if (Member::currentUserID()) { $details = array('Name' => Member::currentUser()->getName(), 'Email' => Member::currentUser()->Email); } else { $details = $form->getSavedStepByClass('EventRegisterTicketsStep'); $details = $details->loadData(); } $link = Controller::join_links($this->getForm()->getController()->Link(), 'confirm', $registration->ID, '?token=' . $registration->Token); $regLink = Controller::join_links($datetime->Event()->Link(), 'registration', $registration->ID, '?token=' . $registration->Token); $email->setTo($details['Email']); $email->setSubject(sprintf('Confirm Registration For %s (%s)', $datetime->getTitle(), $config->Title)); $email->setTemplate('EventRegistrationConfirmationEmail'); $email->populateTemplate(array('Name' => $details['Name'], 'Registration' => $registration, 'RegLink' => $regLink, 'Title' => $datetime->getTitle(), 'SiteConfig' => $config, 'ConfirmLink' => Director::absoluteURL($link))); $email->send(); Session::set("EventRegistration.{$registration->ID}.message", $datetime->Event()->EmailConfirmMessage); } else { $registration->Status = 'Valid'; $registration->write(); } return true; }
/** * make sure to return TRUE as response if the message is sent * successfully * Sends a message from the current user to someone else in the networkd * @param Int | String | Member $to - * @param String $message - Message you are sending * @param String $link - Link to send with message - NOT USED IN EMAIL * @param Array - other variables that we include * @return Boolean - return TRUE as success */ public static function send_message($to, $message, $link = "", $otherVariables = array()) { //FROM if (!empty($otherVariables["From"])) { $from = $otherVariables["From"]; } else { $from = Email::getAdminEmail(); } //TO if ($to instanceof Member) { $to = $to->Email; } //SUBJECT if (!empty($otherVariables["Subject"])) { $subject = $otherVariables["Subject"]; } else { $subject = substr($message, 0, 30); } //BODY $body = $message; //CC if (!empty($otherVariables["CC"])) { $cc = $otherVariables["CC"]; } else { $cc = ""; } //BCC $bcc = Email::getAdminEmail(); //SEND EMAIL $email = new Email($from, $to, $subject, $body, $bounceHandlerURL = null, $cc, $bcc); return $email->send(); }
function action_index() { if ($_POST) { $feedback = ORM::factory('feedback'); try { $feedback->values($_POST, array('title', 'text')); $feedback->type = 1; $feedback->user_id = $this->user->id; $feedback->date = Date::formatted_time(); $feedback->save(); $email_view = View::factory('email/feedback')->set('username', $this->user->username)->set('title', $feedback->title)->set('text', $feedback->text)->render(); Email::send('*****@*****.**', array('*****@*****.**', 'Ассоциация автосервисов'), $feedback->title, $email_view, TRUE); Message::clear(); Message::set(Message::SUCCESS, 'Спасибо! Ваше сообщение отправлено администрации сайта'); $this->request->redirect('cabinet'); } catch (ORM_Validation_Exception $e) { Message::set(Message::ERROR, 'Произошла ошибка при отправке сообщения'); $this->errors = $e->errors('models'); $this->values = $_POST; } } $this->view = View::factory('frontend/cabinet/feedback/create_feedback')->set('errors', $this->errors)->set('values', $this->values); $this->template->title = 'Обратная связь'; $this->template->content = $this->view; }
public function action_index() { $view = View::factory('forgot_password'); $this->template->content = $view->render(); if ($this->request->method() === Request::POST) { $email = $this->request->post('email'); $user = new Model_User(); $password_recovery = new Model_Password_Recovery(); $unique_email = $user->unique_email($email); if ($unique_email === true) { throw new Exception("Email is not correct!"); } $view_for_message = View::factory('forgot_password/send_email'); $user_id = $user->get_id($email); $hash = sha1(Security::token()); $view_for_message->user_id = $user_id; $view_for_message->hash = $hash; $create_attemp = $password_recovery->create_attemp($email, $user_id, $hash); if (!$create_attemp) { throw new Exception("Cannot create attemp!"); } Email::connect(); $to = array($email); $from = array('user@localhost', 'admin'); $subject = 'Password recovery'; $message = $view_for_message->render(); $send_email = Email::send($to, $from, $subject, $message, true); if (!$send_email) { throw new Exception("Cannot send email! \n {$send_email}"); } $this->redirect('/'); } }
public function sendEmail($emailbody, $time, $value, $options) { global $user, $session; $timeformated = DateTime::createFromFormat("U", (int) $time); $timeformated->setTimezone(new DateTimeZone($this->parentProcessModel->timezone)); $timeformated = $timeformated->format("Y-m-d H:i:s"); $tag = array("{id}", "{type}", "{time}", "{value}"); $replace = array($options['sourceid'], $options['sourcetype'], $timeformated, $value); $emailbody = str_replace($tag, $replace, $emailbody); if ($options['sourcetype'] == "INPUT") { $inputdetails = $this->parentProcessModel->input->get_details($options['sourceid']); $tag = array("{key}", "{name}", "{node}"); $replace = array($inputdetails['name'], $inputdetails['description'], $inputdetails['nodeid']); $emailbody = str_replace($tag, $replace, $emailbody); } else { if ($options['sourcetype'] == "VIRTUALFEED") { // Not suported for VIRTUAL FEEDS } } $emailto = $user->get_email($session['userid']); require_once "Lib/email.php"; $email = new Email(); //$email->from(from); $email->to($emailto); $email->subject('Emoncms event alert'); $email->body($emailbody); $result = $email->send(); if (!$result['success']) { $this->log->error("Email send returned error. message='" . $result['message'] . "'"); } else { $this->log->info("Email sent to {$emailto}"); } }
public function addUser($data) { $vData = $data; $validation = Validation::factory($vData); $validation->rule('username', 'not_empty'); $validation->rule('username', 'email'); if (!$validation->check()) { $this->errors = $validation->errors('userErrors'); return FALSE; } $pass = Arr::get($data, 'pass'); $username = addslashes(Arr::get($data, 'username')); $myuser = ORM::factory('Myuser'); $auth = Auth::instance(); $pass = $auth->hash($pass); //Создаем пользователя $myuser->username = $username; $myuser->email = $username; $myuser->password = $pass; $myuser->name = addslashes(Arr::get($data, 'name')); $myuser->phone = addslashes(Arr::get($data, 'phone')); try { $myuser->save(); //Узнаем id пользователя $add_user_id = ORM::factory("user", array("username" => $username))->id; $token = substr($auth->hash($add_user_id . $username), 0, 20); //добавляем роль пользователя $model_addrole = new Model_Addrole(); $model_addrole->user_id = $add_user_id; $model_addrole->role_id = Arr::get($data, "role"); $model_addrole->save(); //добавляем запись для активации $model_addtoken = new Model_Addtoken(); $model_addtoken->user_id = $add_user_id; $model_addtoken->token = $token; $model_addtoken->save(); //отправляем пользователю сообщение для авторизации $config = Kohana::$config->load('email'); $mbase = new Model_Base(); $options = $mbase->getOptions(); Email::connect($config); $to = $username; $subject = 'Добро пожаловать на сайт ' . $options['sitename']; $from = $config['options']['username']; $message = '<b>Отправитель</b>: ' . Kohana::$base_url . '<br>'; $message .= 'Для работы с заказами на сайте Вам необходимо активировать учетную запись. <br> <br> Ваш логин: ' . $username . '<br> Ваш пароль: ' . Arr::get($data, 'pass') . '<br><br> Для активации перейдите по <a href="' . Kohana::$base_url . 'registration?token=' . $token . '&user='******'">этой ссылке</a> <hr> Спасибо за то, что пользуетесь услугами нашего сайта. По всем вопросам обращайтесь в техподдержку: ' . $config['options']['username']; $res = Email::send($to, $from, $subject, $message, $html = TRUE); return $add_user_id; } catch (ORM_Validation_Exception $e) { $this->errors = $e->errors('validation'); return false; } }
/** * @see parent::send() */ public function send() { if (!empty($_FILES['file']['tmp_name'])) { $this->attach($_FILES['file']['tmp_name'], $_FILES['file']['name']); } return parent::send(); }
function action_index() { $services[0] = 'Выбрать компанию'; foreach ($this->user->services->find_all() as $service) { $services[$service->id] = $service->name; } if ($_POST) { $feedback = ORM::factory('feedback'); try { $feedback->values($_POST, array('title', 'text')); $feedback->type = 2; $feedback->user_id = $this->user->id; $feedback->service_id = Arr::get($_POST, 'service_id', 0); $feedback->date = Date::formatted_time(); $feedback->save(); $email_view = View::factory('email/adv')->set('username', $this->user->username)->set('title', $feedback->title)->set('text', $feedback->text); if ($feedback->service_id != 0) { $email_view->set('service', $this->user->services->where('id', '=', $feedback->service_id)->find()); } $email_view->render(); Email::send('*****@*****.**', array('*****@*****.**', 'Ассоциация автосервисов'), $feedback->title, $email_view, TRUE); Message::set(Message::SUCCESS, 'Спасибо! Ваше заявка принята на рассмотрение администрацией сайта'); $this->request->redirect('cabinet'); } catch (ORM_Validation_Exception $e) { $this->errors = $e->errors('models'); $this->values = $_POST; } } $this->view = View::factory('frontend/cabinet/adv/create_blank')->set('services', $services)->set('errors', $this->errors)->set('values', $this->values); $this->template->title = 'Реклама на сайте'; $this->template->bc['#'] = $this->template->title; $this->template->content = $this->view; }
public function action_ajax_add_feedback() { if ($_POST) { $errors = array('name' => 'false', 'text' => 'false', 'email' => 'false', 'check' => 'false', 'phone' => 'false'); if (Validation::factory($_POST)->rule('email', 'email')->rule('email', 'not_empty')->check()) { $errors['email'] = 'true'; } if (Validation::factory($_POST)->rule('phone', 'not_empty')->check()) { $errors['phone'] = 'true'; } if (Validation::factory($_POST)->rule('name', 'not_empty')->check()) { $errors['name'] = 'true'; } if (Validation::factory($_POST)->rule('text', 'not_empty')->check()) { $errors['text'] = 'true'; } $check = arr::get($_POST, 'check'); if (!$check) { $errors['check'] = 'true'; } if ($errors['name'] == 'true' && $errors['email'] == 'true' && $errors['phone'] == 'true' && $errors['text'] == 'true' && $errors['check'] == 'true') { $feedback = ORM::factory('Feedback'); $feedback->name = arr::get($_POST, 'name'); $feedback->phone = arr::get($_POST, 'phone'); $feedback->email = arr::get($_POST, 'email'); $feedback->text = arr::get($_POST, 'text'); $feedback->save(); Email::send('*****@*****.**', array('*****@*****.**', 'Trip-Shop'), 'Новый отзыв', 'Имя - ' . arr::get($_POST, 'name') . '<br/>' . 'Email - ' . arr::get($_POST, 'email') . '<br/>' . 'Телефон - ' . arr::get($_POST, 'phone') . '<br/>' . arr::get($_POST, 'text'), true); } echo json_encode($errors); } else { $this->forward_404(); } }
/** * @param $from (Domain) * @param $to (Email) * @param $subject * @param $message * @return boolean True or False */ public static function sendStandardEmail($from, $to, $subject, $message) { $headers = "From: no-reply@{$from} \r\nMIME-Version: 1.0\r\nContent-Type: text/html; charset=UTF-8\r\n"; $message = '<html> <head></head> <body style="background: #f4f3f1; margin: 0px; padding: 0px;"> <table style="margin: 20px auto; width: 880px; background: #fff; border: 1px #dfdfdf solid; padding: 10px;"> <tr> <td> <a target="_blank" href="//' . $from . '" style="width: 131px; height: 44px; margin: 6px 0px 6px 0px; float: left;"> <img src ="//' . $from . '/images/logo.png"/> </a> </td> </tr> <tr> <td> <h1 style="color: #ff7346; font-weight: normal; margin: 5px 10px; font-size: 15pt; font-family: arial;">' . $subject . '</h1> </td> </tr> <tr> <td> <div style="margin: 5px 10px; font-family: arial; color: #3d3d3d;">' . $message . '</div> </td> </tr> </table> </body> </html>'; return Email::send($to, $subject, $message, $headers); }
public function form(SS_HTTPRequest $request) { /* echo "<pre>"; echo print_r($request); echo "<hr>"; echo print_r($_POST); echo "</pre>"; echo $_SERVER['HTTP_REFERER']; */ $data = $_POST; $email = new Email(); $email->setTo('*****@*****.**'); $email->setFrom($data['Email']); $email->setSubject("Contact Message from " . $data["Name"]); $messageBody = "\n\t\t\t<p><strong>Name:</strong> {$data['Name']}</p>\n\t\t\t<p><strong>Message:</strong> {$data['Message']}</p>\n\t\t"; $email->setBody($messageBody); $email->send(); /* return array( 'Content' => '<p>Thank you for your feedback.</p>', 'Form' => '' ); */ $this->redirect($_SERVER['HTTP_REFERER'] . "?status=success"); }
/** * Sends a report of the parsing and social update. * @param $to [string] e-mail address to send the report to * @param $errors [array] list of errors * @param $notices [array] list of notices * @todo Make template based (plain text and/or HTML using Mailer::setHtml()). * @todo This function should probably be in the SocialUpdate class, as well as the error/notice handling. */ function sendReport($to, &$errors, &$notices) { if (!$to) { return; } $errorCount = count($errors); $from = Config::$siteName . " <no-reply@" . $_SERVER['SERVER_NAME'] . ">"; $subject = $errorCount ? "Update error" : "Update successful"; if ($errorCount) { $msg = "Your update was not processed because of the following error(s):\n\n"; foreach ($errors as $error) { $msg .= "- {$error}\n\n"; } } else { if (count($notices)) { $msg = "Your update was successful:\n\n"; foreach ($notices as $notice) { $msg .= "- {$notice}\n\n"; } } else { $msg = "Your update was successful."; } } $email = new Email($from, $to, $subject); $email->setPlain($msg); $email->send(); }
public function action_process_user_payments() { // уведомляем пользователей, у которых осталось мало времени пользования аккаунтом $disable_event_period = DB::select('days')->from('payment_settings')->where('status', '=', 'N')->where('system_name', '=', 'disable_event_period')->limit(1)->execute()->get('days'); if (empty($disable_event_period)) { $disable_event_period = 5; } $date = new DateTime(); $date->modify($disable_event_period - 1 . " days"); $exp = ORM::factory('user')->where(DB::expr('DATE(expires)'), '=', $date->format("Y-m-d")); $exp->reset(FALSE); if (count($exp->find_all()) > 0) { Email::connect(); $exp_date = $date->format("d.m.Y"); $title = "Действие вашего аккаунта заканчивается"; $text = "Добрый день, %s.<br><br>Действие вашего аккаунта заканчивается %s.<br>Вы можете продлить аккаунт в <a href='http://www.as-avtoservice.ru/cabinet/payment'>личном кабинете</a>"; foreach ($exp->find_all() as $e) { Email::send($e->email, array('*****@*****.**', 'Ассоциация автосервисов'), $title, sprintf($text, $e->username, $exp_date), TRUE); echo "date: " . $exp_date . " email: " . $e->email . "\n"; } } // 1) ставим статус просрочен всем $payment_expires_period = DB::select('days')->from('payment_settings')->where('status', '=', 'N')->where('system_name', '=', 'payment_expires_period')->limit(1)->execute()->get('days'); if (empty($payment_expires_period)) { $payment_expires_period = 5; } $date = new DateTime(); $date->modify("-" . $payment_expires_period . " days"); DB::update("invoice")->set(array('status' => 'E'))->where('status', '=', 'N')->where('create_date', '<', $date->format("Y-m-d"))->execute(); $date = new DateTime(); // Вимикаєм користувачів з просроченими кабінетами $query = DB::update("users")->set(array('user_type' => 'disabled'))->where_open()->where('expires', '<', $date->format("Y-m-d"))->or_where('expires', '=', NULL)->where_close()->execute(); }
public function action_index() { if ($_POST) { $message = html::chars((string) arr::get($_POST, 'message', '')); if ($message) { // Append user information if ($user = $this->auth->get_user()) { $message .= '<h2>Användarinfo</h2>'; $message .= '<dl>'; foreach (array('id', 'username', 'email') as $field) { $message .= sprintf('<dt>%s</dt><dd>%s</dd>', $field, html::chars($user->{$field})); } $message .= '</dl>'; } $from = arr::extract($_POST, array('e-mail', 'name')); if (!Validate::email($from['e-mail'])) { $from['name'] .= " ({$from['e-mail']})"; $from['e-mail'] = '*****@*****.**'; } $sent = Email::send('*****@*****.**', array($from['e-mail'], $from['name']), '[Änglarna Stockholm] Meddelande från kontaktsidan', $message, TRUE); if ($sent >= 1) { $this->message_add('Ditt meddelande har skickats till ' . html::mailto('*****@*****.**') . '!'); } else { $this->message_add('Något blev fel. Försök igen eller skicka ett vanligt mail till ' . html::mailto('*****@*****.**') . ' istället.', 'error'); } } else { $this->message_add('Du måste ange ett meddelande.', 'error'); } $this->request->reload(); } $this->template->title = 'Kontakta Änglarna Stockholm'; $this->template->content = View::factory('kontakt/index'); }
/** * Отправка письма на восстановление пароля * @return */ public function action_forgot_password() { $this->template->title = $this->site_name . 'Восстановление пароля'; $this->template->bc['#'] = 'Восстановление пароля'; if ($_POST) { $validation = Validation::factory($_POST)->rule('username_email', 'not_empty'); if ($validation->check()) { $have_user = DB::select('email', 'id', 'username')->from('users')->where('username', '=', $validation['username_email'])->or_where('email', '=', $validation['username_email'])->execute()->current(); if ($have_user) { //echo $have_user; $key = md5($validation['username_email']); DB::insert('recover_passwords', array('key', 'user_id'))->values(array($key, $have_user['id']))->execute(); $email_view = View::factory('email/recover_password')->set('username', $have_user['username'])->set('key', $key)->render(); Email::send($have_user['email'], array('*****@*****.**', 'Ассоциация автосервисов'), 'Восстановление пароля', $email_view, true); $view = View::factory('frontend/auth/forgot_send_email_complete'); $this->template->content = $view; return; } else { $this->errors['username_email'] = 'Такой пользователь не найден'; } } else { $this->errors = $validation->errors('registration'); } } $this->view = View::factory('frontend/auth/forgot')->set('values', $this->values)->set('errors', $this->errors); $this->template->content = $this->view; }
public function postInsert($event) { $company = $this->getCreator()->getGroups()->getFirst(); // notify it-admins if ($company) { $subject = Email::generateSubject($this); $text = 'Заявка от компании ' . $company->getName() . ', пользователь ' . $this->getCreator()->getUsername() . PHP_EOL . 'http://helpdesk.f1lab.ru/tickets/' . $this->getId(); // sms if (true == ($notify = $company->getNotifySms())) { $phones = []; foreach ($notify as $user) { if ($user->getPhone()) { $phones[] = $user->getPhone(); } } Sms::send($phones, $text); } // email if (true == ($notify = $company->getNotifyEmail())) { $emails = []; foreach ($notify as $user) { if ($user->getEmailAddress()) { $emails[] = $user->getEmailAddress(); } } Email::send($emails, $subject, $text); } } // send email to creator $to = $this->getRealSender() ?: $this->getCreator()->getEmailAddress(); Email::send($to, Email::generateSubject($this), EmailTemplate::newTicket($this)); }
private function sendMessage(NewsletterSentMessage $sent, LiveCart $application) { $config = $application->getConfig(); $email = new Email($application); $email->setTemplate('newsletter/template'); $email->set('subject', $this->subject->get()); $email->set('htmlMessage', $this->html->get()); $email->set('text', $this->text->get()); $email->set('email', $this->text->get()); $email->setFrom($config->get('NEWSLETTER_EMAIL') ? $config->get('NEWSLETTER_EMAIL') : $config->get('MAIN_EMAIL'), $config->get('STORE_NAME')); if ($user = $sent->user->get()) { $email->setTo($user->email->get(), $user->getName()); $email->set('email', $user->email->get()); } else { if ($subscriber = $sent->subscriber->get()) { $email->setTo($subscriber->email->get()); $email->set('email', $subscriber->email->get()); } } //$sent->time->set(new ARExpressionHandle('NOW()')); $sent->save(); if ($this->status->get() == self::STATUS_NOT_SENT) { $this->status->set(self::STATUS_PARTIALLY_SENT); $this->time->set(new ARExpressionHandle('NOW()')); $this->save(); } return $email->send(); }
public function action_index() { $this->template->head = 'Registration'; if (Auth::instance()->logged_in()) { $this->redirect('message'); } else { if ($post = $this->request->post()) { try { $checkusername = ORM::factory('User')->where('username', '=', $this->request->post('username'))->find()->as_array(); $checkemail = ORM::factory('User')->where('email', '=', $this->request->post('email'))->find()->as_array(); if (!empty($checkusername['username'])) { $data['errorsignin'] = 'You are entered an existing username'; } elseif (!empty($checkemail['email'])) { $data['errorsignin'] = 'You are entered an existing email!'; } elseif ($this->request->post('password') !== $this->request->post('password_confirm')) { $data['errorsignin'] = 'You are not confirm your password'; } else { $user = ORM::factory('User')->create_user($_POST, array('username', 'email', 'password')); $user->add('roles', ORM::factory('Role', array('name' => 'login'))); $config = Kohana::$config->load('email'); Email::connect($config); $to = $this->request->post('email'); $subject = 'Message from Kohana!'; $from = '*****@*****.**'; $message = "Congratulations. You have successfully registered<br>" . "Login: "******"<br>Password: "******"login"); } } catch (ORM_Validtion_Exception $e) { $errors = $e->errors('models'); } } $this->template->content = View::factory('reg', $data); } }
public static function exception($exception, $trace = true) { static::log($exception); ob_get_level() and ob_end_clean(); $message = $exception->getMessage(); $file = $exception->getFile(); $code = $exception->getCode(); $response = "<html>\n<h2>Unhandled Exception</h2>\n<h3>Message:</h3>\n<pre>(" . $code . ") " . $message . "</pre>\n<h3>Location:</h3>\n<pre>" . $file . " on line " . $exception->getLine() . "</pre>\n"; if ($trace) { $response .= "<h3>Stack Trace:</h3>\n<pre>" . $exception->getTraceAsString() . "</pre>\n"; } $response .= "</html>"; Response::code(500); if (Config::item("errors", "show", false)) { echo $response; } if (Config::item("errors", "email", false) && !Request::isLocal() && !Request::isPreview()) { $e = new Email(); $e->from = Config::item("errors", "emailFrom", "*****@*****.**"); $e->to = Config::item("errors", "emailTo", "*****@*****.**"); $e->subject = URL::root() . " - erro!"; $e->content = $response; $e->send(); } return exit(1); }
public function run($request) { $sent = 0; if (WorkflowInstance::get()->count()) { // Don't attempt the filter if no instances -- prevents a crash $active = WorkflowInstance::get()->innerJoin('WorkflowDefinition', '"DefinitionID" = "WorkflowDefinition"."ID"')->filter(array('WorkflowStatus' => array('Active', 'Paused'), 'RemindDays:GreaterThan' => '0')); $active->filter(array('RemindDays:GreaterThan' => '0')); if ($active) { foreach ($active as $instance) { $edited = strtotime($instance->LastEdited); $days = $instance->Definition()->RemindDays; if ($edited + $days * 3600 * 24 > time()) { continue; } $email = new Email(); $bcc = ''; $members = $instance->getAssignedMembers(); $target = $instance->getTarget(); if (!$members || !count($members)) { continue; } $email->setSubject("Workflow Reminder: {$instance->Title}"); $email->setBcc(implode(', ', $members->column('Email'))); $email->setTemplate('WorkflowReminderEmail'); $email->populateTemplate(array('Instance' => $instance, 'Link' => $target instanceof SiteTree ? "admin/show/{$target->ID}" : '')); $email->send(); $sent++; $instance->LastEdited = time(); $instance->write(); } } } echo "Sent {$sent} workflow reminder emails.\n"; }
public function run($request) { $sent = 0; $filter = '"WorkflowStatus" IN (\'Active\', \'Paused\') AND "RemindDays" > 0'; $join = 'INNER JOIN "WorkflowDefinition" ON "DefinitionID" = "WorkflowDefinition"."ID"'; $active = DataObject::get('WorkflowInstance', $filter, null, $join); if ($active) { foreach ($active as $instance) { $edited = strtotime($instance->LastEdited); $days = $instance->Definition()->RemindDays; if ($edited + $days * 3600 * 24 > time()) { continue; } $email = new Email(); $bcc = ''; $members = $instance->getAssignedMembers(); $target = $instance->getTarget(); if (!$members || !count($members)) { continue; } $email->setSubject("Workflow Reminder: {$instance->Title}"); $email->setBcc(implode(', ', $members->column('Email'))); $email->setTemplate('WorkflowReminderEmail'); $email->populateTemplate(array('Instance' => $instance, 'Link' => $target instanceof SiteTree ? "admin/show/{$target->ID}" : '')); $email->send(); $sent++; $instance->LastEdited = time(); $instance->write(); } } echo "Sent {$sent} workflow reminder emails.\n"; }
public function postInsert($event) { // send message to ticket creator and observers if (!$this->getSkipNotification()) { // to creator if ($this->getCreatedBy() != $this->getTicket()->getCreatedBy()) { $to = $this->getTicket()->getRealSender() ?: $this->getTicket()->getCreator()->getEmailAddress(); Email::send($to, Email::generateSubject($this->getTicket()), EmailTemplate::newComment($this)); } // to observers and responsibles $usersToNotify = $this->getTicket()->getResponsiblesAndObserversForNotification(); foreach ($usersToNotify as $user) { if ($user->getId() != $this->getCreatedBy() and $user->getId() != $this->getTicket()->getCreatedBy()) { Email::send($user->getEmailAddress(), Email::generateSubject($this->getTicket()), EmailTemplate::newComment($this)); } } } // send messages to mentioned users $mentions = Helpdesk::findMentions($this->getText()); foreach ($mentions as $mention) { if ($mention->getId() != $this->getCreatedBy() and $mention->getId() != $this->getTicket()->getCreatedBy()) { Email::send($mention->getEmailAddress(), Email::generateSubject($this->getTicket()), EmailTemplate::newComment($this, 'mention')); $observingAlready = Doctrine_Query::create()->from('RefTicketObserver ref')->addWhere('ref.user_id = ?', $mention->getId())->addWhere('ref.ticket_id = ?', $this->getTicket()->getId())->count() !== 0; $isResponsible = Doctrine_Query::create()->from('RefTicketResponsible ref')->addWhere('ref.user_id = ?', $mention->getId())->addWhere('ref.ticket_id = ?', $this->getTicket()->getId())->count() !== 0; if (!$observingAlready and !$isResponsible) { $observeRecord = RefTicketObserver::createFromArray(['user_id' => $mention->getId(), 'ticket_id' => $this->getTicket()->getId()]); // workaround for mentions in comments created from email if (!sfContext::getInstance()->getUser()->getGuardUser()) { $observeRecord->setCreatedBy($this->getCreatedBy()); } $observeRecord->save(); } } } }
public function onBeforeWrite() { if ($this->owner->BaseClass == "Discussion" && $this->owner->ID == 0) { $discussion = Discussion::get()->byID($this->owner->ParentID); $discussion_author = $discussion->Author(); $holder = $discussion->Parent(); $author = Member::get()->byID($this->owner->AuthorID); // Get our default email from address if (DiscussionHolder::config()->send_emails_from) { $from = DiscussionHolder::config()->send_email_from; } else { $from = Email::config()->admin_email; } // Vars for the emails $vars = array("Title" => $discussion->Title, "Author" => $author, "Comment" => $this->owner->Comment, 'Link' => Controller::join_links($holder->Link("view"), $discussion->ID, "#comments-holder")); // Send email to discussion owner if ($discussion_author && $discussion_author->Email && $discussion_author->RecieveCommentEmails && $discussion_author->ID != $this->owner->AuthorID) { $subject = _t("Discussions.NewCreatedReplySubject", "{Nickname} replied to your discussion", null, array("Nickname" => $author->Nickname)); $email = new Email($from, $discussion_author->Email, $subject); $email->setTemplate('NewCreatedReplyEmail'); $email->populateTemplate($vars); $email->send(); } // Send to anyone who liked this, if they want notifications foreach ($discussion->LikedBy() as $liked) { if ($liked->RecieveLikedReplyEmails && $liked->Email && $liked->ID != $author->ID) { $subject = _t("Discussions.NewLikedReplySubject", "{Nickname} replied to your liked discussion", null, array("Nickname" => $author->Nickname)); $email = new Email($from, $liked->Email, $subject); $email->setTemplate('NewLikedReplyEmail'); $email->populateTemplate($vars); $email->send(); } } } }
public function SendNewsletterForm($data, $form) { $email = new Email(); $email->setFrom('"mSupply Newsletter Form" <*****@*****.**>')->setTo($this->SiteConfig()->NewsletterFormEmail)->setSubject('mSupply Newsletter Request')->setTemplate('NewsletterSignUpEmail')->populateTemplate(new ArrayData(array('Email' => $data['Email']))); $email->send(); return $this->redirectback(); }
public function after_submit() { Email::send($this->get_field('email')->get_value()->get_raw(), array('*****@*****.**', 'zgol-web.by'), $this->get_field('subject')->get_value()->get_raw(), $this->get_field('answer')->get_value()->get_raw(), TRUE); $model = ORM::factory('Feedback')->where('id', '=', $this->_model->id)->find(); $model->answers++; $model->save(); }
public function sendContactForm($data, $form) { $email = new Email(); $email->setFrom('"mSupply Contact Form" <*****@*****.**>')->setTo($this->SiteConfig()->ContactFormEmail)->setSubject('mSupply Message')->setTemplate('ContactFormEmail')->populateTemplate(new ArrayData(array('FullName' => $data['FullName'], 'Phone' => $data['Phone'], 'Email' => $data['Email'], 'Message' => $data['Message']))); $email->send(); return $this->redirectback(); }