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; }
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 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); } }
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>"); } }
/** * 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); }
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>"; } } }