function send() { $emailService = new EmailService(); $result = $emailService->sendMessage($this->_message); MoblogLogger::log("Response message sent!"); return $result; }
/** * Notifies a user of a new comment in an article. * * @param notification The ArticleNotification object. * @param userInfo An UserInfo object with information about the user (we * mainly will need the email address!) * @param subject Subject of the message that will be sent to the user. * @param body Message that will be sent to the user. * @param charset the encoding that will be used in the message (it should be based * on the locale of the blog who is sending this message) It defaults to iso-8859-1 * @return Returns true if the user was correctly notified or false otherwise. */ function notifyUser($notification, $userInfo, $subject, $body, $charset = 'iso-8859-1') { //print( "sending notification to ".$userInfo->getEmail()."<br/>"); $message = new EmailMessage(); $message->setFrom($this->_config->getValue("post_notification_source_address")); $message->addTo($userInfo->getEmail()); $message->setSubject("pLog Notification system"); $message->setBody($body); $message->setCharset($charset); $service = new EmailService(); return $service->sendMessage($message); }
public function execute() { $server = za()->getConfig('support_mail_server'); $user = za()->getConfig('support_email_user'); $pass = za()->getConfig('support_email_pass'); if (!$server || !$user || !$pass) { // exit! throw new Exception("Configuration incorrect for checking issue emails"); } $emails = $this->emailService->readEmailFrom($server, $user, $pass, true); $this->issueService->processIncomingEmails($emails); }
function action_order() { session_start(); $model = $_SESSION['basket']; $login = $_SESSION["login"]; if (!is_null($_SESSION["login"])) { $account = AccountService::GetByName($login, true); $order = OrderHelper::PopulateOrderFromBasketViewModel($model, $account->account_id); $order = OrderService::Create($order); $products = $model->products; for ($i = 0; $i < count($products); $i++) { for ($j = 0; $j < $model->counts[$i]; $j++) { $orderlist = new OrderList(); $orderlist->order_id = $order->order_id; $orderlist->product_id = $products[$i]->Id; OrderListService::Create($orderlist); } } $_SESSION['basket'] = null; EmailService::SendNewOrderMessage($account, $order->order_id, $model->SumPrice()); $data = $order->order_id; $this->view->generate('Order_view.php', 'template_view.php', $data); } else { header('Location: /Account/login'); } }
function sendNotificationEmail($userInfo) { // if everything went fine, we can now send the confirmation email // only if the user specified a valid email address if ($userInfo->getEmail() != "") { // build an email message $message = new EmailMessage(); $message->setBody($this->_notificationText); $message->setSubject("pLog Notification"); $message->addTo($userInfo->getEmail()); $message->setFrom($this->_userInfo->getEmail()); // and finally send it $emailService = new EmailService(); $emailService->sendMessage($message); } return true; }
public static function sendNotification($serviceName, $message = "", $message_type = ExternalDataNotification::TYPE_ERROR) { $recipients = self::getRecipients(); $res = self::createNotificationMessage($serviceName, $message, $message_type); //sendMultipartMail($res['subject'], $recipients, $res['message'], null, '*****@*****.**', 'enadyskolopassword'); EmailService::sendReport($res['subject'], $recipients, $res['message']); return true; }
/** * sends the email with the request * @private */ function sendResetEmail($userInfo, $url) { // prepare the template $templateService = new TemplateService(); $template = $templateService->Template("resetpasswordemail", "summary"); $template->assign("locale", $this->_locale); $template->assign("reseturl", $url); // render it and keep its contents $emailBody = $template->fetch(); $message = new EmailMessage(); $config =& Config::getConfig(); $message->setFrom($config->getValue("post_notification_source_address")); $message->addTo($userInfo->getEmail()); $message->setSubject("pLog Password Reset Request"); $message->setBody($emailBody); $service = new EmailService(); return $service->sendMessage($message); }
public function execute($request) { $emailConfigurationService = new EmailConfigurationService(); $this->form = new EmailConfigurationForm(array(), array(), true); $this->form->bind($request->getParameter($this->form->getName())); $emailConfiguration = $this->form->populateEmailConfiguration($request); $emailConfigurationService->saveEmailConfiguration($emailConfiguration); if ($request->getParameter('chkSendTestEmail')) { $emailService = new EmailService(); $result = $emailService->sendTestEmail($request->getParameter('txtTestEmail')); if ($result) { $this->getUser()->setFlash('templateMessage', array('SUCCESS', __('Successfully Saved. Test Email Sent'))); } else { $this->getUser()->setFlash('templateMessage', array('WARNING', __("Successfully Saved. Test Email Not Sent"))); } } else { $this->getUser()->setFlash('templateMessage', array('SUCCESS', __(TopLevelMessages::SAVE_SUCCESS))); } $this->redirect('admin/listMailConfiguration'); }
public function execute($request) { $this->setForm(new EmailConfigurationForm()); if ($request->isMethod('post')) { $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $this->form->save(); if ($this->form->getValue('chkSendTestEmail') == 'on') { $emailService = new EmailService(); $result = $emailService->sendTestEmail($this->form->getValue('txtTestEmail')); if ($result) { $this->getUser()->setFlash('success', __('Successfully Saved. Test Email Sent')); } else { $this->getUser()->setFlash('warning', __("Successfully Saved. Test Email Not Sent")); } } else { $this->getUser()->setFlash('success', __(TopLevelMessages::SAVE_SUCCESS)); } $this->redirect('admin/listMailConfiguration'); } } }
public function run() { // echo "sign up model"; $user = $this->propareVO(); // if Email not exists, continue to create if (!UserDAOImpl::findByEmail($user->getEmail())) { $result = UserDAOImpl::doCreate($user); // create user in db if ($result) { // send mail $iEmailService = new EmailService(); $iEmailService->setReceiver($user); $msg = $iEmailService->sendEmail(); // header('location: ../login'); } else { $msg = SQL_EXCEPTION_CREATE_USER; // show error prompt } } else { $msg = SIGN_UP_DUPLICATE_REGISTER; } $controller = new Prompt(); $controller->index($msg); }
function action_new() { $login = $_POST['login']; $pwd = $_POST['pwd']; $email = $_POST['Email']; $inputTelefone = $_POST['inputTelefone']; $model = new RegisterModel(); $model->AccountName = $login; $model->Password = $pwd; $model->Email = $email; $model->Telefone = $inputTelefone; if (!AccountService::IsExistedByName($login)) { $account = AccountHelper::PopulateAccountFromRegisterViewModel($model); $account = AccountService::Create($account); EmailService::SendVerifyNewUserMessage($account, $model->Password, 'http://Store/', 'Account/VerifyNewAccount'); } else { echo 'Данной имя пользовател уже занято'; } }
public function checkAvailability() { $hotelId = 110; $startDate = "2013-10-05"; $endDate = "2013-10-07"; $isHotelAvailable = HotelService::checkAvailability($hotelId, $startDate, $endDate); dmp($isHotelAvailable); if (!$isHotelAvailable) { EmailService::sendNoAvailabilityEmail($hotelId, $startDate, $endDate); } }
function processAutomaticResponse() { $this->log->LogDebug("process automatic response"); $data = JRequest::get('post'); $this->log->LogDebug(serialize($data)); $processorType = JRequest::getVar("processor"); $processor = PaymentService::createPaymentProcessor($processorType); $paymentDetails = $processor->processResponse($data); $this->log->LogDebug("Payment Details: " . serialize($paymentDetails)); if (empty($paymentDetails->confirmation_id)) { return; } $intialPaymentDetails = PaymentService::getConfirmationPaymentDetails($paymentDetails->confirmation_id); $this->log->LogDebug("Initial payment details: " . serialize($intialPaymentDetails)); if ($intialPaymentDetails->payment_status == PAYMENT_STATUS_PAID) { return; } //prevent e-mails to be send again to hotels and customers if ($intialPaymentDetails->payment_status == $paymentDetails->payment_status) { header("HTTP/1.1 200 OK"); return; } //check if the response is a reponse for a waiting transaction $sendMailOnlyToAdmin = $intialPaymentDetails->payment_status == PAYMENT_STATUS_WAITING && $paymentDetails->payment_status == PAYMENT_STATUS_PAID; $this->log->LogDebug("Send only to admin " . serialize($sendMailOnlyToAdmin)); PaymentService::updatePayment($paymentDetails); if ($paymentDetails->status == PAYMENT_CANCELED || $paymentDetails->status == PAYMENT_ERROR) { BookingService::cancelReservation($paymentDetails->confirmation_id); } else { $confirmationModel = $this->getModel("Confirmation"); $reservationDetails = $confirmationModel->getReservation($paymentDetails->confirmation_id); EmailService::sendConfirmationEmail($reservationDetails, $sendMailOnlyToAdmin); //check if hotels has more rooms available $hotelId = $reservationDetails->reservationData->userData->hotelId; $startDate = $reservationDetails->reservationData->userData->start_date; $endDate = $reservationDetails->reservationData->userData->end_date; $isHotelAvailable = HotelService::checkAvailability($hotelId, $startDate, $endDate); if (!$isHotelAvailable) { EmailService::sendNoAvailabilityEmail($hotelId, $startDate, $endDate); } } //http_response_code(200); header("HTTP/1.1 200 OK"); }
function cancelReservation() { $confirmationId = JRequest::getVar('reservationId'); BookingService::cancelReservation($confirmationId); $msg = JText::_('LNG_RESERVATION_CANCELED'); $reservationService = new ReservationService(); $reservationDetails = $reservationService->getReservation($review->confirmation_id); $emailService = new EmailService(); $emailService->sendCancelationEmail($reservationDetails); $this->setRedirect(JRoute::_('index.php?option=' . getBookingExtName() . '&task=customeraccount.managereservations'), $msg); }
function sendConfirmationEmail($reservationDetails) { EmailService::sendConfirmationEmail($reservationDetails); }
public static function sendMessages($isReminder = false) { $items = db()->query("SELECT * FROM nonvalidated_apps_per_owner")->fetchAll(); foreach ($items as $item) { $text = ""; $body = ""; if (is_null($item["contact"])) { error_log("[OutdatedApps]: No contact info for " . $item["ownerid"] . ":" . $item["firstname"] . " " . $item["lastname"]); //TODO: Case where the owner of the application has no contact point continue; } $recipients = array($item["contact"]); $subject = "Notification:"; if (isnull($item["lastsent"]) == false) { $subject = "Reminder:"; } $subject .= "EGI AppDB outdated software profile"; $appids = $item["appids"]; $appids = explode(";", $appids); $appnames = $item["appnames"]; $appnames = explode(";", $appnames); if (count($appids) == 0) { continue; } if (count($appids) == 1) { $template = self::getTemplateBody($item["firstname"] . " " . $item["lastname"]); $body = preg_replace("/\\[1\\]/", "<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("/apps/details?id=" . $appids[0]) . "' target='_blank'>" . $appnames[0] . "</a>", $template); $body = preg_replace("/\\[2\\]/", "<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "' target='_blank'>EGI Applications Database</a>", $body); $body = "<html><head></head><body><pre>" . $body . "</pre></body></html>"; $text = preg_replace("/\\[1\\]/", "" . $appnames[0] . " [1]", $template); $text = preg_replace("/\\[2\\]/", "EGI Applications Database [2]", $text); $text .= "\n\n________________________________________________________________________________________________________\n"; $text .= "[1]. http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("/apps/details?id=" . $appids[0]) . "\n"; $text .= "[2]. http://" . $_SERVER["APPLICATION_UI_HOSTNAME"]; } else { $template = self::getTemplateListBody($item["firstname"] . " " . $item["lastname"]); $listpermalink = "http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode('{"url":"/apps","query":{"flt":"=application.owner:' . $item["ownerid"] . ' +=application.validated:false"},"ext":{"isBaseQuery":true,"append":true,"filterDisplay":"Search outdated...","mainTitle":"Outdated entries"}}'); $body = preg_replace("/\\[1\\]/", "<a href='" . $listpermalink . "' target='_blank'>software</a>", $template); $body = preg_replace("/\\[2\\]/", "<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "' target='_blank'>EGI Applications Database</a>", $body); $body = "<html><head></head><body><pre>" . $body . "</pre></body></html>"; $text = preg_replace("/\\[1\\]/", "software [1]", $template); $text = preg_replace("/\\[2\\]/", "EGI Applications Database [2]", $text); $text .= "\n\n________________________________________________________________________________________________________\n"; $text .= "[1]. " . $listpermalink . " \n"; $text .= "[2]. http://" . $_SERVER["APPLICATION_UI_HOSTNAME"]; $bodylist = ""; $textlist = ""; //Make unique arrays of application ids and names $unames = array(); $uids = array(); for ($i = 0; $i < count($appids); $i += 1) { if (in_array($appids[$i], $uids) === false) { $uids[] = $appids[$i]; $unames[] = $appnames[$i]; } } $appids = $uids; $appnames = $unames; for ($i = 0; $i < count($appids); $i += 1) { $bodylist .= "<div style='padding-left:10px;'>-<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("/apps/details?id=" . $appids[$i]) . "' target='_blank'>" . $appnames[$i] . "</a></div>"; $textlist .= "\t- " . $appnames[$i] . "\n"; } $body = preg_replace("/\\[\\*\\]/", $bodylist, $body); $text = preg_replace("/\\[\\*\\]/", $textlist, $text); } if (ApplicationConfiguration::isProductionInstance() === FALSE) { error_log("SENDING OUTDATED TO:"); error_log("SUBJECT:" . $subject); error_log("RECIPIENTS: " . var_export($recipients, true)); error_log("BODY: " . $text); echo "<div style='background-color:lightgrey;border:1px solid black'><b>subject:</b>" . $subject . "</div><div style='background-color:lightgrey;margin-bottom:10px;border:1px solid black'><b>TO:</b>" . implode(",", $recipients) . "</div><div style='background-color:lightgreen;border:1px solid black;'>" . $body . "</div><div style='background-color:#99DBFF;margin-bottom:10px;border:1px solid black'><pre>" . $text . "</pre></div>"; } else { //sendMultipartMail($subject,$recipients,$text,$body,'*****@*****.**','enadyskolopassword','*****@*****.**',null, false,array("Precedence"=>"bulk")); EmailService::sendBulkReport($subject, $recipients, $text, $body, EmailConfiguration::getSupportAddress()); } } if (APPLICATION_ENV === "production") { db()->query("INSERT INTO app_validation_log (appid) SELECT DISTINCT id FROM applications, (SELECT string_to_array(array_to_string(array_agg(array_to_string(ids,',')),','),',') as ids FROM (SELECT string_to_array(appids, ';') as ids FROM (SELECT * FROM nonvalidated_apps_per_owner) AS t) as tt) as ttt WHERE id::text = ANY(ttt.ids)")->fetchAll(); } return true; }
/** * Send email as user email address using the report account. Report account * credentials must be configured in application.ini or enviroment in order * to function. The replyto field of the email will be the impersonation email. * * @parma string $from Impersonation email address * @param string $subject Email subject text * @param array $to Array of recipients' email addresses * @param string $textbody Text representation of email body * @param string $htmlbody Html representation of email body * @param array $attachment Attachement array as provided from the EmailService::createAttachment function * @param array $cc Array of recipient email addresses where the email carbon copied * @return boolean */ public static function sendReportAsUser($from, $subject, $to, $textbody = '', $htmlbody = '', $attachment = null, $cc = false) { $ext = null; if (trim($from) !== '') { $ext = array("From" => $from); } else { $from = false; } return EmailService::sendReport($subject, $to, $textbody, $htmlbody, $from, $attachment, $cc, $ext); }
function sendPaymentDetailsEmail($data) { $orderTable = JTable::getInstance("Order", "JTable", array()); $orderTable->load($data->order_id); $properties = $orderTable->getProperties(1); $order = JArrayHelper::toObject($properties, 'JObject'); $order->details = $data; $companiesTable = $this->getTable("Company"); $company = $companiesTable->getCompany($order->company_id); $packageTable = $this->getTable("Package"); $order->package = $packageTable->getPackage($order->package_id); if (!isset($company->email)) { return; } return EmailService::sendPaymentDetailsEmail($company, $order); }
/** * Processes incoming emails so that issues can be created/updated * * @param unknown_type $emails */ public function processIncomingEmails($emails) { foreach ($emails as $mail) { // First we need to find which customer the email belongs to $from = ifset($mail->headers, 'from', false); if (!$from) { za()->log("Failed finding from email header in " . print_r($mail, true)); continue; } // clean it up a bit if (!preg_match("/[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}/i", $from, $matches)) { za()->log("Error finding valid email address", Zend_Log::ERR); continue; } $email = $matches[0]; // Get the contact now. If it doesn't exist that's okay, it // might be a system user instead. $contact = $this->clientService->getContactByField('email', $email); // If not found by primary, try secondary if (!$contact) { $contact = $this->clientService->getContactByField('altemail', $email); } // We'll also see whether this issue was sent in by a user // of the system. $user = $this->userService->getUserByField('email', $email); if (!$contact && !$user) { za()->log("No valid user found with 'from' address {$email}", Zend_Log::WARN); $this->trackerService->track('invalid-issue-email', $email, null, null, serialize($mail)); continue; } // Next up, see if the contact has an associated user, because // we'll add them in as the 'creator' of the issue if ($contact != null) { $contactUser = $this->userService->getUserbyField('contactid', $contact->id); if ($contactUser != null) { $user = $contactUser; } } if ($user != null) { za()->setUser($user); } $params = array(); // Saving a new issue uses the title of the email $subject = ifset($mail->headers, 'subject', false); if (!$subject) { // we'll accept an empty subject, just create a default title $subject = "Support request from {$from}"; } $textBody = $this->emailService->getTextBody($mail); $issue = null; // Try and get an existing ticket za()->log("Checking email subject {$subject}"); if (preg_match("/#(\\d+)/", $subject, $matches)) { // existing $id = $matches[1]; $issue = $this->getIssue($id); if ($issue) { za()->log("Adding note to request {$id}"); // Make sure the issue found currently belongs to the contact // client! // if there's no contact, make sure there's a user instead if ($contact) { if ($issue->clientid != $contact->clientid) { $issue = null; } } else { if (!$user) { $issue = null; } } } else { $this->log->warn("Request not found for id {$id}"); } } $infoText = ""; if ($user) { $infoText = "Email coming from user #" . $user->id . " - " . $user->username . " "; } if ($contact) { $infoText = "Email coming from contact #" . $contact->id . " - " . $contact->firstname . " "; } $this->trackerService->track('incoming-issue-email', $email, null, null, "Processing email from " . $email . ": " . $infoText); $notifyOfId = false; // If we've already got an issue, it means we're wanting to // just update its comments if ($issue) { // Just add an additional comment to the // current issue. $poster = $contact ? $contact->firstname : $user->getUsername(); $note = $this->notificationService->addNoteTo($issue, $textBody, $subject, $poster); $this->notificationService->sendWatchNotifications($note, array('controller' => 'issue', 'action' => 'edit', 'params' => array('id' => $issue->id))); za()->log("Note added to request {$issue->id}", Zend_Log::INFO); } else { // new $issue = new Issue(); $issue->title = $subject; $issue->description = $textBody; $issue->issuetype = 'Support'; // Send a notification to the user that the report was received, // with the bug ID in it so the user knows what to respond to $notifyOfId = !is_null($contact); } if ($contact) { $issue->clientid = $contact->clientid; } $this->saveIssue($issue); // Go through the attachments for the email, if any $attachments = $this->emailService->getEmailAttachments($mail); $i = 1; foreach ($attachments as $emailAttachment) { $this->addAttachmentToIssue($issue, $emailAttachment, $i); $i++; } if ($notifyOfId) { $model = array('issue' => $issue, 'contact' => $contact); $receipient = new User(); $receipient->username = $contact->firstname; $receipient->email = $contact->email; $subject = "New request created: #{$issue->id}"; $msg = $this->notificationService->generateEmail('new-issue-contact.php', $model); $this->trackerService->track('notify-request-sender', $receipient->username, null, null, $subject); $this->notificationService->notifyUser($subject, array($receipient), $msg, ifset($mail->headers, 'to', null), 'Support'); } } }
public static function sendPermissionsRequest($userid, $apikeyid, $msg) { //Get sender $users = new Default_Model_Researchers(); $users->filter->id->equals($userid); if ($users->count() == 0) { return "Sender not found"; } $user = $users->items[0]; //Get sender's primary email $contacts = new Default_Model_Contacts(); $contacts->filter->isprimary->equals(true)->and($contacts->filter->researcherid->equals($userid)); if ($contacts->count() == 0) { return "Sender has no primary e-mail set"; } //Check if e-mail has value $useremail = $contacts->items[0]->data; if (trim($useremail) == '') { return "Sender has no valid primary e-mail set"; } //Get api key $apikeys = new Default_Model_APIKeys(); $apikeys->filter->id->equals($apikeyid)->and($apikeys->filter->ownerid->equals($userid)); if (count($apikeys) == 0) { return "Api key not found"; } $apikey = $apikeys->items[0]; //Get Appdb administrators $recipients = array(); $admins = new Default_Model_Researchers(); $agmf = new Default_Model_ActorGroupMembersFilter(); $agmf->groupid->numequals(-1); // admins $admins->filter->chain($agmf, "AND"); if (count($admins->items) == 0) { return ""; } //Get admins primary emails $admins = $admins->items; foreach ($admins as $admin) { $contacts = new Default_Model_Contacts(); $contacts->filter->isprimary->equals(true)->and($contacts->filter->researcherid->equals($admin->id))->and($contacts->filter->contacttypeid->equals(7)); if (count($contacts->items) == 0) { continue; } if (trim($contacts->items[0]->data) !== '') { $recipients[] = $contacts->items[0]->data; } } $recipients = array_unique($recipients); if (count($recipients) == 0) { return ""; } $textbody = self::getMailBody($user, $apikey, $msg); //Get text body and also set html body $body = preg_replace("/\\</", "<", $textbody); $body = preg_replace("/\\>/", ">", $body); $body = preg_replace("/\n/", "<br/>", $body); $body = preg_replace("/\t/", "<span style='padding-left:10px;'></span>", $body); $body = preg_replace("/\\[1\\]/", "<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("/people/details?id=" . $user->id) . "' target='_blank' title='View person's entry in EGI AppDB' >" . $user->firstname . " " . $user->lastname . "</a>", $body); $body = preg_replace("/\\[2\\]/", "<b>" . $apikey->key . "</b>", $body); $body = "<html><head></head><body>" . $body . "</body></html>"; $textbody = preg_replace("/\t/", " ", $textbody); $textbody = preg_replace("/\\[1\\]/", $user->firstname . " " . $user->lastname . " [id: " . $user->id . ", url: http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("/people/details?id=" . $user->id) . "]", $textbody); $textbody = preg_replace("/\\[2\\]/", $apikey->key, $textbody); $subject = "EGI AppDB: API Permissions request from user " . $user->firstname . " " . $user->lastname; //sendMultipartMail($subject,$recipients, $textbody, $body, '*****@*****.**', 'enadyskolopassword',$useremail); EmailService::sendReport($subject, $recipients, $textbody, $body, $useremail); return true; }
public function submitAction() { if ($this->session->userid !== null) { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $type = $this->_getParam("type"); $entryID = $this->_getParam("entryID"); $comment = $this->_getParam("comment"); $reason = $this->_getParam("reason"); switch ($reason) { case self::REASON_OTHER: $reason_str = 'Other'; break; case self::REASON_COPYRIGHT_ISSUE: $reason_str = 'Copyright Issue'; break; case self::REASON_INAPPROPRIATE_CONTENT: $reason_str = 'Inappropriate Content'; break; case self::REASON_INVALID_DATA: $reason_str = 'Invalid or False Data'; break; case self::REASON_OUT_OF_DATE: $reason_str = 'Out of Date Information'; break; case self::REASON_BROKEN_LINK: $reason_str = 'Broken Link'; break; case self::REASON_SPELLING: $reason_str = 'Typo/Misspelling'; break; default: $reason_str = 'Other'; break; } $offender = "id={$entryID}"; $subject = "AppDB report"; if (ApplicationConfiguration::isEnviroment("production")) { $to = EmailConfiguration::getList('ucst'); } else { $to = EmailConfiguration::getList('debug'); } $offenderApp = ""; $body = "EGI Applications Database Abuse Report \n\n" . "A user has submitted a report concerning a" . (in_array(strtolower(substr($type, 0, 1)), array('a', 'e', 'i', 'o', 'u')) ? "n" : "") . " " . $type . "\n\n"; $body = "--------------------------------------------------\n"; $body .= "Please do not reply, this is an automated message.\n"; $body .= "--------------------------------------------------\n\n"; if ($type == "application") { $subject .= " - problem on content"; $body .= "EGI Applications Database problem report on content \n\n"; $body .= "A user has submitted a problem report concerning the software "; $apps = new Default_Model_Applications(); $apps->filter->id->equals($entryID); if (count($apps->items) > 0) { $offender = $apps->items[0]->name . ' (http://' . $_SERVER['HTTP_HOST'] . '/?p=' . base64_encode('/apps/details?id=' . $apps->items[0]->id) . ")"; $body .= $apps->items[0]->name . " with id: " . $apps->items[0]->id; } } elseif ($type == "comment") { $subject .= " - abuse on comment"; $body .= "EGI Applications Database abuse report on a comment\n\n"; $body .= "A user has submitted an abuse report concerning the software "; $aprs = new Default_Model_AppRatings(); $aprs->filter->id->equals($entryID); if (count($aprs->items) > 0) { $cid = $apps->items[0]->id; $apps = new Default_Model_Applications(); $apps->filter->id->equals($aprs->items[0]->appid); if (count($apps->items[0]) > 0) { $body .= $apps->items[0]->name . " with id: " . $apps->items[0]->id; $rs = new Default_Model_Researchers(); $rs->filter->id->equals($aprs->items[0]->submitterid); if (count($rs->items) > 0) { $commentPersonName = $rs->items[0]->firstname . ' ' . $rs->items[0]->lastname; } else { $commentPersonName = 'a guest user'; } $commentDate = new DateTime($aprs->items[0]->submittedon); $commentDate = $commentDate->format('Y-m-d H:i'); $offenderApp = "Offensive software entry: " . $apps->items[0]->name . ' (http://' . $_SERVER['HTTP_HOST'] . '/?p=' . base64_encode('/apps/details?id=' . $apps->items[0]->id) . ")\n"; $offender = "submitted by {$commentPersonName} on {$commentDate} (Comment ID: {$entryID})"; } } } $body = $body . "\n\n"; $body .= $offenderApp . "Offensive " . $type . " entry: " . $offender . "\n" . 'Submitter: ' . $this->session->fullName . ' (http://' . $_SERVER['HTTP_HOST'] . '/?p=' . base64_encode('/people/details?id=' . $this->session->userid) . ")\n" . "Reason: " . $reason_str . "\n\n" . "Description: " . $comment . "\n"; //sendMultipartMail($subject, $to, $body,"<pre>".$body."</pre>", '*****@*****.**', 'enadyskolopassword'); EmailService::sendReport($subject, $to, $body, "<pre>" . $body . "</pre>"); } }
private static function sendConfirmationEmail($session, $pending) { $researcher = $pending->getResearcher(); $email = $researcher->getPrimaryContact(); $accounttype = str_replace("-", " ", trim($pending->accountType)); $accountname = trim($pending->accountName) === "" ? $pending->accountID : $pending->accountName; $res = "Dear " . $researcher->name . ",\n\n"; $res .= " a request has been made to connect the " . $accounttype . " account of " . $accountname . "\n"; $res .= "to your profile in the EGI Applications Database [1].\n"; $res .= "If it is really you the one that made this request and you wish to proceed with the account connection\n"; $res .= " - go to the EGI Applications Database Portal[1] and\n"; $res .= " - sign in with the same " . $accounttype . " account.\n"; $res .= "The system will prompt you with a form where you should enter the confirmation code bellow:\n\n"; $res .= " Confirmation Code: " . $pending->code . "\n\n"; $res .= "Note: The confirmation code expires 30 minutes after this message was sent.\n\n"; $res .= "If you are not the one that made this request, then please report the incident by replying to this message.\n\n"; $res .= "Best regards,\n"; $res .= "EGI AppDB team\n"; $res .= "\n\n__________________________________________________\n"; $res .= "[1]. http://" . $_SERVER["APPLICATION_UI_HOSTNAME"]; $subject = "EGI AppDB: Request to connect " . $accounttype . " account to your profile"; $text = $res; $body = $body = preg_replace("/\n/", "<br/>", $res); $body = "<div>" . $body . "</div>"; //DEVELOPMENT CODE if (ApplicationConfiguration::isProductionInstance() === FALSE) { error_log("\nSending to: " . $email); error_log("\n\n" . $res); } $recipients = array($email); //sendMultipartMail($subject,$recipients,$text,$body,'*****@*****.**','enadyskolopassword','*****@*****.**',null, false,array("Precedence"=>"bulk")); EmailService::sendBulkReport($subject, $recipients, $text, $body, EmailConfiguration::getSupportAddress()); }
function perform() { // extract the data $recipients = $this->_request->getValue("messageRecipient"); $recipientsCc = $this->_request->getValue("messageCc"); $recipientsBcc = $this->_request->getValue("messageBcc"); $text = $this->_request->getValue("messageText"); $subject = $this->_request->getValue("messageSubject"); // check that we've got either a 'to','cc' or 'bcc' if ($recipients == "" && $recipientsCc == "" && $recipientsBcc == "") { // force an error $this->_view = new MailCentreSendMessageView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->tr("mailcentre_error_sending_message")); $this->_form->setFieldValidationStatus("messageRecipient", false); $this->setCommonData(true); } // pre-process some of the data $recipients = str_replace(" ", "", $recipients); $recipientsCc = str_replace(" ", "", $recipientsCc); $recipientsBcc = str_replace(" ", "", $recipientsBcc); // and get the list of recipients $listUnexpanded = explode(",", $recipients); $list = array(); foreach ($listUnexpanded as $recipient) { $result = $this->_expandRecipients($recipient); $list = array_merge($list, $result); } $listCcUnexpanded = explode(",", $recipientsCc); $listCc = array(); foreach ($listCcUnexpanded as $recipient) { $result = $this->_expandRecipients($recipient); $listCc = array_merge($listCc, $result); } $listBccUnexpanded = explode(",", $recipientsBcc); $listBcc = array(); foreach ($listBccUnexpanded as $recipient) { $result = $this->_expandRecipients($recipient); $listBcc = array_merge($listBcc, $result); } // create a mail message that includes all the recipients $message = new EmailMessage(); $val = new EmailValidator(); $totalTo = 0; $totalCc = 0; $totalBcc = 0; foreach ($list as $to) { // add each one of the recipients if ($val->validate($to)) { $message->addTo($to); $totalTo++; } } foreach ($listCc as $cc) { // add each one of the recipients if ($val->validate($cc)) { $message->addCc($cc); $totalCc++; } } foreach ($listBcc as $bcc) { // add each one of the recipients if ($val->validate($bcc)) { $message->addBcc($bcc); $totalBcc++; } } // check that we are really sending the message to somebody if ($totalTo == 0 && $totalCc == 0 && $totalBcc == 0) { // force an error $this->_view = new MailCentreSendMessageView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->tr("mailcentre_error_sending_message")); $this->_form->setFieldValidationStatus("messageRecipient", false); $this->setCommonData(true); } // and now set the subject and body... $message->setSubject($subject); $message->setBody($text); // set the encoding based on the current blog settings $locale =& $this->_blogInfo->getLocale(); $message->setCharset($locale->getCharset()); // and the "from" address $config =& Config::getConfig(); $from = $config->getValue("post_notification_source_address"); $message->setFrom($from); // now send the message $service = new EmailService(); if (!$service->sendMessage($message)) { // if something went wrong, go back to the previous view $this->_view = new MailCentreSendMessageView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->tr("mailcentre_error_sending_message")); // show the view and keep the data that was in the form $this->setCommonData(true); } $recipients = implode(",", $list); $recipientsCc = implode(",", $listCc); $recipientsBcc = implode(",", $listBcc); // if everything went ok, create our own MailMessage object and save it to the database $mailMessage = new MailMessage($subject, $text, $recipients, $recipientsCc, $recipientsBcc); $mailMessages = new MailMessages(); $mailMessages->addMessage($mailMessage); // show the resulting view $this->_view = new MailCentreMessageListView($this->_blogInfo); $this->_view->setSuccessMessage($this->_locale->tr("mailcentre_message_sent_ok")); $this->setCommonData(); return true; }
function sendInvoiceEmail($hotel, $email, $status) { $mode = 1; //html $ret = true; if ($status == 0) { //JMail::sendMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=null, $bcc=null, $attachment=null, $replyto=null, $replytoname=null) $ret = EmailService::sendEmail($email->company_email, $email->company_name, $email->company_email, $hotel->email, null, null, $email->subject, $email->content, $mode); } else { $appSettings = JHotelUtil::getApplicationSettings(); $emailAddress = ''; if ($appSettings->send_invoice_to_email) { $emailAddress = $appSettings->invoice_email; } else { $emailAddress = $hotel->email; } //JMail::sendMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=null, $bcc=null, $attachment=null, $replyto=null, $replytoname=null) $ret = EmailService::sendEmail($email->company_email, $email->company_name, $email->company_email, $emailAddress, null, null, $email->subject, $email->content, $mode); } return $ret; }
public static function sendSubscriptionVerificationTextMail($subscription) { $actions = array(); $delivery = array(); $users = new Default_Model_Researchers(); $subject = "EGI AppDB: Email subscription verification"; $body = ""; $nl = "\r\n"; $t = "\t"; //Find subscriber in researchers $users->filter->id->equals($subscription->researcherid); $users->refresh(); if (count($users->items) == 0) { error_log("[appdb:Subscription Verification Email] : Could not find user with id = " . $subscription->researcherID . " . Delivery cancelled."); return; } $user = $users->items[0]; //Get event types of subscriptions if (NewsEventType::has($subscription->events, NewsEventType::E_INSERT) == true) { $actions[] = "new software"; } if (NewsEventType::has($subscription->events, NewsEventType::E_UPDATE) == true) { $actions[] = "software updates"; } if (NewsEventType::has($subscription->events, NewsEventType::E_INSERT_CONTACT) == true) { $actions[] = "new contacts"; } if (NewsEventType::has($subscription->events, NewsEventType::E_INSERT_COMMENT) == true) { $actions[] = "new comments"; } //Get delivery types of subscriptions if (NewsDeliveryType::has($subscription->delivery, NewsDeliveryType::D_DAILY_DIGEST) == true) { $delivery[] = "daily"; } if (NewsDeliveryType::has($subscription->delivery, NewsDeliveryType::D_WEEKLY_DIGEST) == true) { $delivery[] = "every monday"; } if (NewsDeliveryType::has($subscription->delivery, NewsDeliveryType::D_MONTHLY_DIGEST) == true) { $delivery[] = "every 1st day of the month"; } $body = "Dear " . $user->firstName . " " . $user->lastName . "," . $nl . $nl; $body .= "Your request to receive e-mail notifications about '" . $subscription->name . "' has been processed. " . $nl . $nl; //Render actions (events) $body .= "You will be notified for"; if (count($actions) == 1) { $body .= " " . $actions[0]; } else { $ac = count($actions); for ($i = 0; $i < $ac; $i += 1) { $body .= " " . $actions[$i]; if ($i == $ac - 2) { $body .= ($ac > 2 ? "," : "") . " and"; } else { if ($i < $ac - 1) { $body .= ","; } } } } $body .= "." . $nl; //Render delivery $body .= "The delivery of notifications will take place"; if (count($delivery) == 1) { $body .= " " . $delivery[0]; } else { $dc = count($delivery); for ($i = 0; $i < $dc; $i += 1) { $body .= " " . $delivery[$i]; if ($i == $dc - 2) { $body .= ($dc > 2 ? "," : "") . " and"; } else { if ($i < $dc - 1) { $body .= ","; } } } } $body .= "." . $nl . $nl; $body .= 'If no new software registrations (or updates of existing software) occur within the given delivery time span, no e-mail will be sent.' . $nl . $nl; $body .= "Sincerely," . $nl; $body .= "EGI AppDB notifications service" . $nl; $body .= "website: http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "/"; //Get primary e-mail contact of subscriber and send e-mail $rs = new Default_Model_Contacts(); $rs->filter->researcherid->equals($subscription->researcherid)->and($rs->filter->contacttypeid->equals(7))->and($rs->filter->isprimary->equals(true)); if (count($rs->refresh()->items) > 0) { $to = $rs->items[0]->data; //sendMultipartMail($subject, $to, $body,'', '*****@*****.**', 'enadyskolopassword'); EmailService::sendReport($subject, $to, $body); error_log("[appdb:Subscription Verification Email]: Sending subscription verification to " . $to); } else { error_log("[appdb:Subscription Verification Email]: Cannot find a primary e-mail for user with id = " . $subscription->researcherid); } }
public static function sendMessage($appid, $userid, $recipientid, $message) { //Get sender $users = new Default_Model_Researchers(); $users->filter->id->equals($userid); if ($users->count() == 0) { return "Sender not found"; } $user = $users->items[0]; //Get sender's primary email $contacts = new Default_Model_Contacts(); $contacts->filter->isprimary->equals(true)->and($contacts->filter->researcherid->equals($userid)); if ($contacts->count() == 0) { return "Sender has no primary e-mail set"; } $useremail = $contacts->items[0]->data; //Get recipient $recipients = new Default_Model_Researchers(); $recipients->filter->id->equals($recipientid); if ($recipients->count() == 0) { return "Recipient not found"; } $recipient = $recipients->items[0]; //Get recipient's primary email $contacts = new Default_Model_Contacts(); $contacts->filter->isprimary->equals(true)->and($contacts->filter->researcherid->equals($recipientid)); if ($contacts->count() == 0) { return "Recipient has no primary e-mail set"; } $recipientmail = $contacts->items[0]->data; //Get application $applications = new Default_Model_Applications(); $applications->filter->id->equals($appid); if ($applications->count() == 0) { return "Software not found"; } $app = $applications->items[0]; //Decode message $message = base64_decode($message); if (strlen(trim($message)) === 0) { return "Message is empty"; } //Get text body and also set html body $textbody = self::getTextBody($app, $user, $useremail, $recipient, $message); $body = preg_replace("/\\</", "<", $textbody); $body = preg_replace("/\\>/", ">", $body); $body = preg_replace("/\n/", "<br/>", $body); $body = preg_replace("/\t/", "<span style='padding-left:10px;'></span>", $body); $body = preg_replace("/\\[1\\]/", "<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "' target='_blank' title='Visit EGI Applications Database' >EGI AppDB</a>", $body); $body = preg_replace("/\\[2\\]/", "<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("//people/details?id=" . $user->id) . "' target='_blank' title='View person's entry in EGI AppDB' >" . $user->firstname . " " . $user->lastname . "</a>", $body); $body = preg_replace("/\\[3\\]/", "'<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("/apps/details?id=" . $app->id) . "' target='_blank' title='View software entry in EGI AppDB' >" . $app->name . "</a>'", $body); $body = "<html><head></head><body>" . $body . "</body></html>"; $textbody = preg_replace("/\t/", " ", $textbody); $textbody = preg_replace("/\\[1\\]/", "EGI AppDB [1]", $textbody); $textbody = preg_replace("/\\[2\\]/", $user->firstname . " " . $user->lastname . " [2]", $textbody); $textbody = preg_replace("/\\[3\\]/", "'" . $app->name . "' [3]", $textbody); $textbody .= "\n\n________________________________________________________________________________________________________\n"; $textbody .= "[1]. http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "\n"; $textbody .= "[2]. http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("/people/details?id=" . $user->id) . "\n"; $textbody .= "[3]. http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("/apps/details?id=" . $app->id) . " \n"; $subject = "EGI Applications Database: " . $user->firstname . " " . $user->lastname . " sent you a message"; if (trim($useremail) === '') { $useremail = false; } //sendMultipartMail($subject,$recipientmail, $textbody, $body, '*****@*****.**', 'enadyskolopassword',$useremail, null, false, array("From"=>$useremail)); EmailService::sendReportAsUser($useremail, $subject, $recipientmail, $textbody, $body); }
function sendCancellationEmail($reservationId) { $reservationService = new ReservationService(); $reservationDetails = $reservationService->getReservation($reservationId); return EmailService::sendCancelationEmail($reservationDetails); }
public static function sendEmailResponseNotification($user, $app, $stateid = 0, $type = 'joinapplication') { $recipients = self::getUserPrimaryEmail($user->id); if (($stateid == 2 || $stateid == 3) && count($recipients) > 0) { $state = $stateid == 2 ? "Accepted" : "Rejected"; $subject = "EGI Applications Database: " . $state . " request to join software " . $app->name . " response"; if ($type == 'releasemanager') { $subject = "EGI Applications Database: " . $state . " request to manage releases for software " . $app->name . " response"; } $textbody = self::getResponseEmailBody($user, $app, $stateid, $type); $body = preg_replace("/\n/", "<br/>", $textbody); $body = preg_replace("/\t/", "<span style='padding-left:10px;'></span>", $body); $body = preg_replace("/\\[1\\]/", "'<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("/apps/details?id=" . $app->id) . "' target='_blank' title='View software entry in EGI AppDB'>" . $app->name . "</a>'", $body); $body = "<html><head></head><body>" . $body . "</body></html>"; $textbody = preg_replace("/\t/", " ", $textbody); $textbody = preg_replace("/\\[1\\]/", "'" . $app->name . "' [1]", $textbody); $textbody .= "\n\n________________________________________________________________________________________________________\n"; $textbody .= "[1]. http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "?p=" . base64_encode("/apps/details?id=" . $app->id) . " \n"; if (ApplicationConfiguration::isProductionInstance() === FALSE) { error_log("SENDING TO: " . $recipients); error_log("SUBJECT: " . $subject); error_log("MESSAGE: " . $textbody); } //sendMultipartMail($subject,$recipients, $textbody, $body, '*****@*****.**', 'enadyskolopassword'); EmailService::sendReport($subject, $recipients, $textbody, $body); } }
private static function sendNotification($notification) { $subject = $notification["subject"]; $to = $notification["recipient"]; $txtbody = $notification["message"]; if (ApplicationConfiguration::isProductionInstance() === FALSE) { self::debugSendMultipart($subject, $to, $txtbody, null, "appdb reports username", "appdb reports password", false, null, false, null); } else { //sendMultipartMail($subject, $to, $txtbody, null, '*****@*****.**', 'enadyskolopassword', false, null, false, array("Precedence"=>"bulk")); EmailService::sendBulkReport($subject, $to, $txtbody); } }
public function feedbackAction() { $this->_helper->layout->disableLayout(); if ($_SERVER["REQUEST_METHOD"] == "GET") { $this->view->src = isset($_GET["src"]) ? $_GET["src"] : null; $this->view->username = ""; $this->view->contacts = array(); if ($this->session->userid !== null) { $this->view->username = $this->session->fullName; $cnts = new Default_Model_Contacts(); $cnts->filter->researcherid->equals($this->session->userid)->and($cnts->filter->contacttypeid->equals(7)); if (count($cnts->items) > 0) { $this->view->contacts = $cnts->items; } } else { $this->view->captcha = $this->generateCaptchaForm(); } } else { if ($_SERVER["REQUEST_METHOD"] == "POST") { $this->_helper->viewRenderer->setNoRender(); $feedback = isset($_POST["feedback"]) && trim($_POST["feedback"]) !== "" ? $_POST["feedback"] : ""; $subject = isset($_POST["subject"]) && trim(stripslashes($_POST["subject"])) !== "" ? stripslashes($_POST["subject"]) : "<no subject>"; $email = isset($_POST["email"]) && trim(stripslashes($_POST["email"])) !== "" ? stripslashes($_POST["email"]) : ""; $cc = isset($_POST["cc"]) && trim($_POST["cc"]) !== "" ? $_POST["cc"] : false; $name = isset($_POST["name"]) && trim($_POST["name"]) !== "" ? $_POST["name"] : "anonymous"; $captchaid = isset($_POST["captchaid"]) && trim($_POST["captchaid"]) !== "" ? $_POST["captchaid"] : ""; $captcha = isset($_POST["captcha"]) && trim($_POST["captcha"]) !== "" ? $_POST["captcha"] : ""; header("Content-type: text/xml; charset=utf-8"); echo '<' . '?xml version="1.0"?' . '>'; if ($feedback == "") { echo "<response error='no feedback given' group='feedback'></response>"; return; } if ($email == "") { echo "<response error='no email given' group='email'></response>"; return; } $bodyheader = "----------------------------------------------------------------------------\n"; $bodyheader .= "Feedback from user: "******" " . ($this->session->userid !== null ? "(id:" . $this->session->userid . ")" : "") . " \n"; $bodyheader .= "User email: " . $email . " \n"; $bodyheader .= "----------------------------------------------------------------------------\n\n"; //Make receivers array if (strpos($email, ";") !== false) { $emailto = explode(";", $email); $email = array(); for ($i = 0; $i < count($emailto); $i += 1) { $emailto[$i] = trim($emailto[$i]); if ($emailto[$i] !== "") { $email[] = $emailto[$i]; } } } else { $email = array($email); } //Validate email format for ($i = 0; $i < count($email); $i += 1) { if (!preg_match('/^([0-9a-z]+[-._+&])*[0-9a-z]+@([-0-9a-z]+[.])+[a-z]{2,6}$/i', $email[$i])) { echo "<response error='Email " . $email[$i] . " is invalid' group='email'></response>"; return; } } $body = base64_decode($feedback); $body = stripslashes($body); if (trim($body) == "") { echo "<response error='no feedback given' group='feedback'></response>"; return; } if (preg_match("/(\r|\n)(to:|from:|cc:|bcc:)/i", $body)) { echo "<response error='Message body contains invalid headers' group='feedback'></response>"; return; } if ($this->session->userid === null) { if (trim($captchaid) == "" && trim($captcha) == "") { echo "<response error='Must login first to send message'></response>"; return; } $sessionkey = "Zend_Form_Captcha_" . $captchaid; if (isset($_SESSION[$sessionkey]) && isset($_SESSION[$sessionkey]["word"]) && $_SESSION[$sessionkey]["word"] == $captcha) { } else { echo "<response error='Security word is wrong' group='captcha'></response>"; return; } } $subject = "[AppDB Portal Feedback]: " . $subject; $body = $bodyheader . $body; //Send email $recs = array(EmailConfiguration::getSupportAddress()); $ccemails = false; if ($cc == true) { $ccemails = $email; } //sendMultipartMail($subject,$recs, $body, '', '*****@*****.**', 'enadyskolopassword', $email[0], null, $ccemails); EmailService::sendReport($subject, $recs, $body, '', $email[0], null, $ccemails); $to = ""; foreach ($email as $e) { if (trim($to) !== "") { $to .= ";"; } $to .= $e; } echo "<response to='" . htmlspecialchars($to, ENT_QUOTES) . "' subject='" . htmlspecialchars($subject, ENT_QUOTES) . "' cc='" . $cc . "' >" . htmlspecialchars($body, ENT_QUOTES) . "</response>"; } } }