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(); }
/** * 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; }
/** * Notify admin of new comment * * @param Comment $comment */ public function onAfterPostComment(Comment $comment) { // Determine recipient $recipient = CommentsNotifications::get_recipient($comment->getParent()); if (empty($recipient)) { return; } // Check moderation status if (Config::inst()->get('CommentsNotifications', 'only_unmoderated') && $comment->Moderated) { return; } // Generate email $email = new Email(); $email->setSubject(Config::inst()->get('CommentsNotifications', 'email_subject')); $email->setTo($recipient); $email->setTemplate(Config::inst()->get('CommentsNotifications', 'email_template')); $email->populateTemplate($comment); // Corretly set sender and from as per email convention $sender = Config::inst()->get('CommentsNotifications', 'email_sender'); if (!empty($comment->Email)) { $email->setFrom($comment->Email); $email->addCustomHeader('Reply-To', $comment->Email); } else { $email->setFrom($sender); } $email->addCustomHeader('X-Sender', $sender); $email->addCustomHeader('Sender', $sender); $this->owner->extend('updateEmail', $email); // Send $email->send(); }
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"); }
/** * Send comment notification to a given recipient * * @param Comment $comment * @param DataObject $parent Object with the {@see CommentNotifiable} extension applied * @param Member|string $recipient Either a member object or an email address to which notifications should be sent */ public function notifyCommentRecipient($comment, $parent, $recipient) { $subject = $parent->notificationSubject($comment, $recipient); $sender = $parent->notificationSender($comment, $recipient); $template = $parent->notificationTemplate($comment, $recipient); // Validate email // Important in case of the owner being a default-admin or a username with no contact email $to = $recipient instanceof Member ? $recipient->Email : $recipient; if (!$this->isValidEmail($to)) { return; } // Prepare the email $email = new Email(); $email->setSubject($subject); $email->setFrom($sender); $email->setTo($to); $email->setTemplate($template); $email->populateTemplate(array('Parent' => $parent, 'Comment' => $comment, 'Recipient' => $recipient)); if ($recipient instanceof Member) { $email->populateTemplate(array('ApproveLink' => $comment->ApproveLink($recipient), 'HamLink' => $comment->HamLink($recipient), 'SpamLink' => $comment->SpamLink($recipient), 'DeleteLink' => $comment->DeleteLink($recipient))); } // Until invokeWithExtensions supports multiple arguments if (method_exists($this->owner, 'updateCommentNotification')) { $this->owner->updateCommentNotification($email, $comment, $recipient); } $this->owner->extend('updateCommentNotification', $email, $comment, $recipient); return $email->send(); }
function testSendingAnEmail() { $email = new Email(self::getApplication()); $email->setSubject('test'); $email->setText('some text'); $email->setFrom('*****@*****.**', 'Unit Test'); $email->setTo('*****@*****.**', 'Recipient'); $res = $email->send(); $this->assertEqual($res, 1); }
function sendEmail($data, $form) { $email = new Email(); $email->setTo($data['Email']); $email->setFrom($data['Email']); $email->setSubject('A subject with some umlauts: öäüß'); $email->setBody('A body with some umlauts: öäüß'); $email->send(); echo "<p>email sent to " . $data['Email'] . "</p>"; }
public function sendPushNotification(PushNotification $notification) { $email = new Email(); $email->setFrom($this->getSetting('From')); $email->setSubject($this->getSetting('Subject')); $email->setBody($notification->Content); foreach ($notification->getRecipients() as $recipient) { $email->setTo($recipient->Email); $email->send(); } }
public function submit($data, $form) { $email = new Email(); $email->setTo('*****@*****.**'); $email->setFrom($data['Email']); $email->setSubject("Contact Message from {$data["Name"]}"); $messageBody = " \n <p><strong>Name:</strong> {$data['Name']}</p> \n <p><strong>Message:</strong> {$data['Message']}</p> \n "; $email->setBody($messageBody); $email->send(); return array('Content' => '<p>Thank you for your feedback.</p>', 'Form' => ''); }
public function sendEmail($data, Form $form) { $email = new Email(); $email->setTo('*****@*****.**'); $email->setFrom($data['Email']); $email->setSubject("Contact Message from {$data["Name"]}"); $messageBody = "\n <p><strong>Name:</strong> {$data['Name']}</p>\n <p><strong>Email:</strong> {$data['Email']}</p>\n <p><strong>Phone:</strong> {$data['Phone']}</p>\n <p><strong>School:</strong> {$data['School']}</p>\n <p><strong>Module:</strong> {$data['Module']}</p>\n <p><strong>Message:</strong> {$data['Message']}</p>\n "; $email->setBody($messageBody); $email->send(); return array('Content' => '<p>Thank you for your feedback.</p>', 'Form' => ''); }
public function doContact(array $data) { $email = new Email(); $email->setTo(Email::getAdminEmail()); $email->setFrom($data['Email']); $email->setSubject(_t('ContactForm.SUBJECT', 'ContactForm.SUBJECT') . $data['Name']); $email->setBody($data['Message']); //$email->set $email->send(); $this->sessionMessage(_t('ContactForm.SUCCESS', 'ContactForm.SUCCESS'), 'good'); $this->controller->redirectBack(); }
public function send() { if (!$this->buildValidator()->isValid()) { return new ActionRedirectResponse('contactForm', 'index'); } $email = new Email($this->application); $email->setTemplate('contactForm/contactForm'); $email->setFrom($this->request->get('email'), $this->request->get('name')); $email->setTo($this->config->get('NOTIFICATION_EMAIL'), $this->config->get('STORE_NAME')); $email->set('message', $this->request->get('msg')); $email->send(); return new ActionRedirectResponse('contactForm', 'sent'); }
function doContact($data, $form) { //Send an email to the support $email = new Email(); $email->setSubject("Contact Us form submitted"); $email->setFrom($data['Email']); $email->setTo('*****@*****.**'); //$email->setTo('*****@*****.**'); $email->setTemplate('ContactUsEmail'); $email->populateTemplate(array('Name' => $data['Name'], 'Email' => $data['Email'], 'Phone' => $data['Phone'], 'Topic' => $data['Topic'], 'Message' => $data['Message'])); $email->send(); $form->sessionMessage('Your email has been sent. Thank you for your message. Someone will respond back to you within 24-48 hours.', 'success'); return $this->redirectBack(); }
/** * @param int $ownerID * @param array|SS_List $pages */ protected function notifyOwner($ownerID, SS_List $pages) { $owner = self::$member_cache[$ownerID]; $sender = Security::findAnAdministrator(); $senderEmail = $sender->Email ? $sender->Email : Config::inst()->get("Email", "admin_email"); $subject = _t("ContentReviewEmails.SUBJECT", "Page(s) are due for content review"); $email = new Email(); $email->setTo($owner->Email); $email->setFrom($senderEmail); $email->setTemplate("ContentReviewEmail"); $email->setSubject($subject); $email->populateTemplate(array("Recipient" => $owner, "Sender" => $sender, "Pages" => $pages)); $email->send(); }
/** * Adds or modifies a job on the website. * * @param array $data * @param Form $form */ public function doJobForm() { $data = $this->request->postVars(); $form = new JobBoardForm($this); $form->loadDataFrom($data); $existed = false; if (!isset($data['JobID']) && !$data['JobID']) { $job = new Job(); } else { $job = Job::get()->byId($data['JobID']); $existed = true; if ($job && !$job->canEdit()) { return $this->owner->httpError(404); } else { $job = new Job(); } } $form->saveInto($job); $job->isActive = true; $job->write(); Session::set('JobID', $job->ID); $member = Member::get()->filter(array('Email' => $data['Email']))->first(); if (!$member) { $member = new Member(); $member->Email = $SQL_email; $member->FirstName = isset($data['Company']) ? $data['Company'] : false; $password = Member::create_new_password(); $member->Password = $password; $member->write(); $member->addToGroupByCode('job-posters', _t('Jobboard.JOBPOSTERSGROUP', 'Job Posters')); } $member->logIn(); $job->MemberID = $member->ID; $job->write(); if (!$existed) { $email = new Email(); $email->setSubject($data['EmailSubject']); $email->setFrom($data['EmailFrom']); $email->setTo($member->Email); // send the welcome email. $email->setTemplate('JobPosting'); $email->populateTemplate(array('Member' => $member, 'Password' => isset($password) ? $password : false, 'FirstPost' => $password ? true : false, 'Holder' => $this, 'Job' => $job)); if ($notify = $form->getController()->getJobNotifyAddress()) { $email->setBcc($notify); } $email->send(); } return $this->redirect($data['BackURL']); }
public function execute(WorkflowInstance $workflow) { $members = $workflow->getAssignedMembers(); if (!$members || !count($members)) { return true; } $member = Member::currentUser(); $initiator = $workflow->Initiator(); $contextFields = $this->getContextFields($workflow->getTarget()); $memberFields = $this->getMemberFields($member); $initiatorFields = $this->getMemberFields($initiator); $variables = array(); foreach ($contextFields as $field => $val) { $variables["\$Context.{$field}"] = $val; } foreach ($memberFields as $field => $val) { $variables["\$Member.{$field}"] = $val; } foreach ($initiatorFields as $field => $val) { $variables["\$Initiator.{$field}"] = $val; } $pastActions = $workflow->Actions()->sort('Created DESC'); $variables["\$CommentHistory"] = $this->customise(array('PastActions' => $pastActions, 'Now' => SS_Datetime::now()))->renderWith('CommentHistory'); $from = str_replace(array_keys($variables), array_values($variables), $this->EmailFrom); $subject = str_replace(array_keys($variables), array_values($variables), $this->EmailSubject); if ($this->config()->whitelist_template_variables) { $item = new ArrayData(array('Initiator' => new ArrayData($initiatorFields), 'Member' => new ArrayData($memberFields), 'Context' => new ArrayData($contextFields), 'CommentHistory' => $variables["\$CommentHistory"])); } else { $item = $workflow->customise(array('Items' => $workflow->Actions(), 'Member' => $member, 'Context' => new ArrayData($contextFields), 'CommentHistory' => $variables["\$CommentHistory"])); } if ($this->ListingTemplateID) { $template = DataObject::get_by_id('ListingTemplate', $this->ListingTemplateID); $view = SSViewer::fromString($template->ItemTemplate); } else { $view = SSViewer::fromString($this->EmailTemplate); } $body = $view->process($item); foreach ($members as $member) { if ($member->Email) { $email = new Email(); $email->setTo($member->Email); $email->setSubject($subject); $email->setFrom($from); $email->setBody($body); $email->send(); } } return true; }
public function createEmail($member) { //error_log("LOG MESSAGE FROM FORUM EMAIL POST DECORATOR LINK IS ".$this->owner->AbsoluteLink()); $controller = new SubscribeController(); $email = new Email(); $from_email = $this->owner->Forum()->parent()->FromEmail; $email->setFrom($from_email); $reply_to = $this->owner->Forum()->parent()->ReplyTo; $email->addCustomHeader('Reply-To', $reply_to); $email->setTo($member->Email); $config = SiteConfig::current_site_config(); $email->setSubject($this->owner->Title . ' | ' . $config->Title . ' ' . $this->owner->Forum()->Title . ' Forum'); $email->setTemplate('Forum_SubscriberNotification'); $email->populateTemplate(array('Recipient' => $member->FirstName, 'Link' => $this->owner->Link(), 'Title' => $this->owner->Title, 'Content' => $this->owner->Content, 'Author' => $this->owner->Author()->Nickname, 'Forum' => $this->owner->Forum()->Title, 'UnsubscribeLinkFromForum' => Director::absoluteBaseURL() . $controller->Link('unsubscribe/' . $this->owner->ForumID))); $email->send(); }
/** * Send an email to the email address set in * this writer. */ public function _write($event) { // If no formatter set up, use the default if (!$this->_formatter) { $formatter = new SS_LogErrorEmailFormatter(); $this->setFormatter($formatter); } $formattedData = $this->_formatter->format($event); $subject = $formattedData['subject']; $data = $formattedData['data']; $email = new Email(); $email->setTo($this->emailAddress); $email->setSubject($subject); $email->setBody($data); $email->setFrom(self::$send_from); $email->send(); }
/** * Send a mail of the order to the client (and another to the admin). * * @param $template - the class name of the email you wish to send * @param $subject - subject of the email * @param $copyToAdmin - true by default, whether it should send a copy to the admin */ public function sendEmail($template, $subject, $copyToAdmin = true) { $from = ShopConfig::config()->email_from ? ShopConfig::config()->email_from : Email::config()->admin_email; $to = $this->order->getLatestEmail(); $checkoutpage = CheckoutPage::get()->first(); $completemessage = $checkoutpage ? $checkoutpage->PurchaseComplete : ""; $email = new Email(); $email->setTemplate($template); $email->setFrom($from); $email->setTo($to); $email->setSubject($subject); if ($copyToAdmin) { $email->setBcc(Email::config()->admin_email); } $email->populateTemplate(array('PurchaseCompleteMessage' => $completemessage, 'Order' => $this->order, 'BaseURL' => Director::absoluteBaseURL())); return $email->send(); }
/** * request approval: sends email to shop admin to request approval. */ function requestapproval($data, $form, $request) { if ($this->member) { $email = new Email(); $email->setTo(Order_Email::get_from_email()); $email->setSubject(_t("EcommerceCorporateAccount.REQUESTINGACCOUNTAPPROVE", "A request for an account approval from ") . $this->member->Email); $email->setTemplate('EcommerceCorporateGroupApprovalRequest'); $config = SiteConfig::current_site_config(); $ecommerceConfig = EcommerceDBConfig::current_ecommerce_db_config(); $email->populateTemplate(array('SiteConfig' => $config, 'EcommerceConfig' => $ecommerceConfig, 'Member' => $this->member)); $email->send(); $form->sessionMessage(_t('EcommerceCorporateAccount.REQUESTHASBEENSENT', 'The request has been sent.'), 'good'); Director::redirectBack(); } else { $form->sessionMessage(_t('EcommerceCorporateAccount.REQUESTCOULDNOTBESEND', 'The request could not be sent.'), 'bad'); Director::redirectBack(); } }
/** * We hook into onAfterWrite() because we want to check this every time the comment is written - primarily because * of the test that we perform to ensure that the comment isn't currently moderated. Most sites will moderate * comments initially, and there's no point sending an email to a user if the comment is still awaiting moderation * (and therefore the user can't see it yet). * * @todo This will lead to multiple emails being sent if a comment is edited after being posted */ public function onAfterWrite() { parent::onAfterWrite(); $parentClass = $this->owner->BaseClass; $parentID = $this->owner->ParentID; // We only want to notify people if certain conditions are met: // - The comment has passed moderation (aka. if required, it has been approved by an admin) // - We are either seeing the Comment for the first time, or it has just passed moderation by an admin if ($this->shouldSendUserNotificationEmails()) { if (ClassInfo::exists($parentClass)) { $commentParent = $parentClass::get()->byID($parentID); // Get all comments attached to this page, which we have to do manually as the has_one relationship is // 'faked' by the Comment class (because it can be attached to multiple parent classes). if ($commentParent) { $comments = Comment::get()->filter(array('BaseClass' => $parentClass, 'ParentID' => $parentID, 'NotifyOfUpdates' => true)); // If we have comments, iterate over them to build a unique list of all email addresses to notify if ($comments) { $emailList = array(); foreach ($comments as $c) { $author = $c->Author(); if ($author) { if (!in_array($author->Email, $emailList)) { $emailList[] = $author->Email; } } } // Send an email to everyone in the list if (sizeof($emailList) > 0) { foreach ($emailList as $emailAddress) { $email = new Email(); $email->setSubject('New Comment on "' . $commentParent->dbObject('Title')->XML() . '"'); $email->setFrom(Email::getAdminEmail()); $email->setTo($emailAddress); $email->populateTemplate($this->owner); $email->send(); } } } } } } }
/** * Deal with sending a notification. This is assumed to be an email * by default, but can be extended through "augmentSend" to allow * adding of additional notification types (such as SMS, XML, etc) * */ public function sendNotification($order) { // Deal with customer email if ($order->Email && ($this->SendNotificationTo == 'Customer' || $this->SendNotificationTo == "Both")) { if ($this->CustomSubject) { $subject = $this->CustomSubject; } else { $subject = _t('Orders.Order', 'Order') . " {$order->OrderNumber} {$order->Status}"; } $email = new Email(); $email->setSubject($subject); $email->setTo($order->Email); if ($this->FromEmail) { $email->setFrom($this->FromEmail); } $email->setTemplate("OrderNotificationEmail_Customer"); $email->populateTemplate(array("Order" => $order, "SiteConfig" => $this->Parent())); $this->extend("augmentEmailCustomer", $email, $order); $email->send(); } // Deal with vendor email if ($this->VendorEmail && ($this->SendNotificationTo == 'Vendor' || $this->SendNotificationTo == "Both")) { if ($this->CustomSubject) { $subject = $this->CustomSubject; } else { $subject = _t('Orders.Order', 'Order') . " {$order->OrderNumber} {$order->Status}"; } $email = new Email(); $email->setSubject($subject); $email->setTo($this->VendorEmail); if ($this->FromEmail) { $email->setFrom($this->FromEmail); } $email->setTemplate("OrderNotificationEmail_Vendor"); $email->populateTemplate(array("Order" => $order)); $this->extend("augmentEmailVendor", $email, $order); $email->send(); } $this->extend("augmentSend", $order); }
public function subscribe() { $email = $this->request->get('email'); if (!$this->user->isAnonymous() || User::getInstanceByEmail($email)) { return new ActionRedirectResponse('newsletter', 'alreadySubscribed'); } $validator = $this->getSubscribeValidator(); if (!$validator->isValid()) { return new ActionRedirectResponse('index', 'index'); } $instance = NewsletterSubscriber::getInstanceByEmail($email); if (!$instance) { $instance = NewsletterSubscriber::getNewInstanceByEmail($email); } $instance->save(); $mail = new Email($this->application); $mail->setTo($email); $mail->setTemplate('newsletter/confirm'); $mail->set('subscriber', $instance->toArray()); $mail->set('email', $email); $mail->send(); return new ActionResponse('subscriber', $instance->toArray()); }
/** * Send comment notification to a given recipient * * @param BlogGuestBookSubmission $submission * @param DataObject $parent Object with the {@see CommentNotifiable} extension applied * @param Member|string $recipient Either a member object or an email address to which notifications should be sent */ public function notifyCommentRecipient($submission, $parent, $recipient) { $subject = $parent->NotificationSubject; $sender = $submission->Email; $template = "BlogGuestBlogEmail"; // Validate email // Important in case of the owner being a default-admin or a username with no contact email $to = $recipient->EmailAddress; if (!$this->isValidEmail($to)) { return; } // Prepare the email $email = new Email(); $email->setSubject($subject); $email->setFrom($sender); $email->setTo($to); $email->setTemplate($template); $email->populateTemplate(array('Parent' => $parent, 'Submission' => $submission, 'Recipient' => $recipient)); if ($recipient instanceof Member) { $email->populateTemplate(array('ApproveLink' => $submission->ApproveLink($recipient), 'HamLink' => $submission->HamLink($recipient), 'SpamLink' => $submission->SpamLink($recipient), 'DeleteLink' => $submission->DeleteLink($recipient))); } return $email->send(); }
public function submit($data, $form) { $config = SiteConfig::current_site_config(); $site_email_address = $config->EmailAddress; if (empty($site_email_address)) { $site_email_address = "*****@*****.**"; } $email = new Email(); $email->setTo($site_email_address); $email->setFrom($data['Email']); $email->setSubject("Contact Message from {$data["Name"]}"); unset($data['url']); unset($data['SecurityID']); unset($data['action_submit']); $messageBody = ""; foreach ($data as $key => $value) { if (!empty($value)) { $messageBody = $messageBody . "<p><strong>" . $key . "</strong> " . $value . "</p>"; } } $email->setBody($messageBody); // $email->send(); return array('Content' => '<p>Thank you for your feedback.</p>', 'Form' => ''); }
/** * @param array $data * @param Form $form */ public function doUnregister($data, $form) { $regos = $this->time->Registrations()->filter('Email', $data['Email']); if (!$regos || !count($regos)) { $form->sessionMessage(_t('EventManager.NOREGFOREMAIL', 'No registrations for the email you entered could be found.'), 'bad'); return $this->redirectBack(); } if ($this->time->Event()->UnRegEmailConfirm) { $addr = $data['Email']; $email = new Email(); $registration = $regos->First(); $email->setTo($addr); $email->setSubject(sprintf(_t('EventManagement.CONFIRMUNREGFOR', 'Confirm Un-Registration For %s (%s)'), $this->time->Event()->Title, SiteConfig::current_site_config()->Title)); $email->setTemplate('EventUnregistrationConfirmationEmail'); $email->populateTemplate(array('Registration' => $registration, 'Time' => $this->time, 'SiteConfig' => SiteConfig::current_site_config(), 'ConfirmLink' => Director::absoluteURL(Controller::join_links($this->Link(), 'confirm', '?email=' . urlencode($addr), '?token=' . $registration->Token)))); $email->send(); } else { foreach ($regos as $rego) { $rego->Status = 'Canceled'; $rego->write(); } } $this->redirect($this->Link('afterunregistration')); }
public function doAlertApprovalForm($data, $form, $request) { $this->owner->setCurrentActionType(self::ACTION_ALERT); $project = $this->owner->DNProjectList()->filter('ID', $data['ProjectID'])->first(); if (!($project && $project->exists())) { $form->sessionMessage('Invalid project. Please re-submit.', 'bad'); return $this->owner->redirectBack(); } if (!defined('DEPLOYNAUT_OPS_EMAIL') || !defined('DEPLOYNAUT_OPS_EMAIL_FROM')) { $form->sessionMessage('This form has not been configured yet. Please try again later.', 'bad'); return $this->owner->redirectBack(); } $email = new Email(); $email->setFrom(DEPLOYNAUT_OPS_EMAIL_FROM); $email->setTo(DEPLOYNAUT_OPS_EMAIL); $email->setSubject('Deploynaut approve alert request'); $email->setTemplate('ApproveAlertEmail'); $email->populateTemplate($data); $email->populateTemplate(['Submitter' => Member::currentUser(), 'Project' => $project]); $email->populateTemplate(['ProjectAlertsLink' => sprintf('%s/naut/project/%s/alerts', BASE_URL, $project->Name)]); $email->send(); $form->sessionMessage('Thank you, your request has been successfully submitted.', 'good'); return $this->owner->redirectBack(); }
public function process() { $service = singleton('QueuedJobService'); $report = $this->getReport(); if (!$report) { $this->currentStep++; $this->isComplete = true; return; } $clone = clone $report; $clone->GeneratedReportTitle = $report->ScheduledTitle; $result = $clone->prepareAndGenerate(); if ($report->ScheduleEvery) { if ($report->ScheduleEvery == 'Custom') { $interval = $report->ScheduleEveryCustom; } else { $interval = $report->ScheduleEvery; } $next = $service->queueJob(new ScheduledReportJob($report, $this->timesGenerated + 1), date('Y-m-d H:i:s', strtotime("+1 {$interval}"))); $report->QueuedJobID = $next; } else { $report->Scheduled = false; $report->QueuedJobID = 0; } $report->write(); if ($report->EmailScheduledTo) { $email = new Email(); $email->setTo($report->EmailScheduledTo); $email->setSubject($result->Title); $email->setBody(_t('ScheduledReportJob.SEE_ATTACHED_REPORT', 'Please see the attached report file')); $email->attachFile($result->PDFFile()->getFullPath(), $result->PDFFile()->Filename, 'application/pdf'); $email->send(); } $this->currentStep++; $this->isComplete = true; }
/** Send an email with a link to unsubscribe from all this user's newsletters */ public function sendUnsubscribeLink(SS_HTTPRequest $request) { //get the form object (we just need its name to set the session message) $form = NewsletterContentControllerExtension::getUnsubscribeFormObject($this); $email = Convert::raw2sql($request->requestVar('email')); $recipient = Recipient::get()->filter('Email', $email)->First(); if ($recipient) { //get the IDs of all the Mailing Lists this user is subscribed to $lists = $recipient->MailingLists()->column('ID'); $listIDs = implode(',', $lists); $days = UnsubscribeController::get_days_unsubscribe_link_alive(); if ($recipient->ValidateHash) { $recipient->ValidateHashExpired = date('Y-m-d H:i:s', time() + 86400 * $days); $recipient->write(); } else { $recipient->generateValidateHashAndStore($days); } $templateData = array('FirstName' => $recipient->FirstName, 'UnsubscribeLink' => Director::absoluteBaseURL() . "unsubscribe/index/" . $recipient->ValidateHash . "/{$listIDs}"); //send unsubscribe link email $email = new Email(); $email->setTo($recipient->Email); $from = Email::getAdminEmail(); $email->setFrom($from); $email->setTemplate('UnsubscribeLinkEmail'); $email->setSubject(_t('Newsletter.ConfirmUnsubscribeSubject', "Confirmation of your unsubscribe request")); $email->populateTemplate($templateData); $email->send(); $form->sessionMessage(_t('Newsletter.GoodEmailMessage', 'You have been sent an email containing an unsubscribe link'), "good"); } else { //not found Recipient, just reload the form $form->sessionMessage(_t('Newsletter.BadEmailMessage', 'Email address not found'), "bad"); } Controller::curr()->redirectBack(); }
/** man_exception::_sendOutEmail() * send out the email to developers@manlinegroup.com * @return true on success false otherwise */ private function _sendOutEmail() { require_once BASE . 'basefunctions/baseapis/communications/Email.class.php'; $email = new Email(); $email->setTo(array('Manline Developers' => '*****@*****.**')); $email->setSubject('Exception: ' . $this->string); $email->setBody($this->_html); if ($email->send() === false) { return false; } return true; }