/**
  * 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();
 }
 public function createEmail($subject = "Website Enquiry", $template = "GenericEmail")
 {
     $content = $this->renderWith("EnquiryEmail_content");
     $to = Email::getAdminEmail();
     $email = new Email($this->Email, $to, $subject);
     $email->setTemplate($template);
     $email->populateTemplate($this);
     $email->populateTemplate(array('Body' => $content));
     $this->extend('updateReceiptEmail', $email);
     return $email;
 }
 public function run($request)
 {
     $sent = 0;
     $filter = '"WorkflowStatus" IN (\'Active\', \'Paused\') AND "RemindDays" > 0';
     $join = 'INNER JOIN "WorkflowDefinition" ON "DefinitionID" = "WorkflowDefinition"."ID"';
     $active = DataObject::get('WorkflowInstance', $filter, null, $join);
     if ($active) {
         foreach ($active as $instance) {
             $edited = strtotime($instance->LastEdited);
             $days = $instance->Definition()->RemindDays;
             if ($edited + $days * 3600 * 24 > time()) {
                 continue;
             }
             $email = new Email();
             $bcc = '';
             $members = $instance->getAssignedMembers();
             $target = $instance->getTarget();
             if (!$members || !count($members)) {
                 continue;
             }
             $email->setSubject("Workflow Reminder: {$instance->Title}");
             $email->setBcc(implode(', ', $members->column('Email')));
             $email->setTemplate('WorkflowReminderEmail');
             $email->populateTemplate(array('Instance' => $instance, 'Link' => $target instanceof SiteTree ? "admin/show/{$target->ID}" : ''));
             $email->send();
             $sent++;
             $instance->LastEdited = time();
             $instance->write();
         }
     }
     echo "Sent {$sent} workflow reminder emails.\n";
 }
 public function process()
 {
     $config = SiteConfig::current_site_config();
     $datetime = $this->getDatetime();
     $emails = $this->emails;
     if (!count($emails)) {
         $this->isComplete = true;
         return;
     }
     $email = new Email();
     $email->setSubject(sprintf(_t('EventManagement.EVENTREMINDERSUBJECT', 'Event Reminder For %s (%s)'), $datetime->EventTitle(), $config->Title));
     $email->setTemplate('EventReminderEmail');
     $email->populateTemplate(array('SiteConfig' => $config, 'Datetime' => $datetime));
     foreach ($emails as $addr => $name) {
         $_email = clone $email;
         $_email->setTo($addr);
         $_email->populateTemplate(array('Name' => $name));
         $_email->send();
         unset($emails[$addr]);
         $this->emails = $emails;
         ++$this->currentStep;
     }
     if (!count($emails)) {
         $this->isComplete = true;
     }
 }
 public function run($request)
 {
     $sent = 0;
     if (WorkflowInstance::get()->count()) {
         // Don't attempt the filter if no instances -- prevents a crash
         $active = WorkflowInstance::get()->innerJoin('WorkflowDefinition', '"DefinitionID" = "WorkflowDefinition"."ID"')->filter(array('WorkflowStatus' => array('Active', 'Paused'), 'RemindDays:GreaterThan' => '0'));
         $active->filter(array('RemindDays:GreaterThan' => '0'));
         if ($active) {
             foreach ($active as $instance) {
                 $edited = strtotime($instance->LastEdited);
                 $days = $instance->Definition()->RemindDays;
                 if ($edited + $days * 3600 * 24 > time()) {
                     continue;
                 }
                 $email = new Email();
                 $bcc = '';
                 $members = $instance->getAssignedMembers();
                 $target = $instance->getTarget();
                 if (!$members || !count($members)) {
                     continue;
                 }
                 $email->setSubject("Workflow Reminder: {$instance->Title}");
                 $email->setBcc(implode(', ', $members->column('Email')));
                 $email->setTemplate('WorkflowReminderEmail');
                 $email->populateTemplate(array('Instance' => $instance, 'Link' => $target instanceof SiteTree ? "admin/show/{$target->ID}" : ''));
                 $email->send();
                 $sent++;
                 $instance->LastEdited = time();
                 $instance->write();
             }
         }
     }
     echo "Sent {$sent} workflow reminder emails.\n";
 }
 public function onBeforeWrite()
 {
     if ($this->owner->BaseClass == "Discussion" && $this->owner->ID == 0) {
         $discussion = Discussion::get()->byID($this->owner->ParentID);
         $discussion_author = $discussion->Author();
         $holder = $discussion->Parent();
         $author = Member::get()->byID($this->owner->AuthorID);
         // Get our default email from address
         if (DiscussionHolder::config()->send_emails_from) {
             $from = DiscussionHolder::config()->send_email_from;
         } else {
             $from = Email::config()->admin_email;
         }
         // Vars for the emails
         $vars = array("Title" => $discussion->Title, "Author" => $author, "Comment" => $this->owner->Comment, 'Link' => Controller::join_links($holder->Link("view"), $discussion->ID, "#comments-holder"));
         // Send email to discussion owner
         if ($discussion_author && $discussion_author->Email && $discussion_author->RecieveCommentEmails && $discussion_author->ID != $this->owner->AuthorID) {
             $subject = _t("Discussions.NewCreatedReplySubject", "{Nickname} replied to your discussion", null, array("Nickname" => $author->Nickname));
             $email = new Email($from, $discussion_author->Email, $subject);
             $email->setTemplate('NewCreatedReplyEmail');
             $email->populateTemplate($vars);
             $email->send();
         }
         // Send to anyone who liked this, if they want notifications
         foreach ($discussion->LikedBy() as $liked) {
             if ($liked->RecieveLikedReplyEmails && $liked->Email && $liked->ID != $author->ID) {
                 $subject = _t("Discussions.NewLikedReplySubject", "{Nickname} replied to your liked discussion", null, array("Nickname" => $author->Nickname));
                 $email = new Email($from, $liked->Email, $subject);
                 $email->setTemplate('NewLikedReplyEmail');
                 $email->populateTemplate($vars);
                 $email->send();
             }
         }
     }
 }
 /**
  * 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();
 }
 /**
  * Form action handler for ContactInquiryForm.
  *
  * @param array $data The form request data submitted
  * @param Form $form The {@link Form} this was submitted on
  */
 function dosave(array $data, Form $form, SS_HTTPRequest $request)
 {
     $SQLData = Convert::raw2sql($data);
     $attrs = $form->getAttributes();
     if ($SQLData['Comment'] != '' || $SQLData['Url'] != '') {
         // most probably spam - terminate silently
         Director::redirect(Director::baseURL() . $this->URLSegment . "/success");
         return;
     }
     $item = new ContactInquiry();
     $form->saveInto($item);
     // $form->sessionMessage(_t("ContactPage.FORMMESSAGEGOOD", "Your inquiry has been submitted. Thanks!"), 'good');
     $item->write();
     $mailFrom = $this->currController->MailFrom ? $this->currController->MailFrom : $SQLData['Email'];
     $mailTo = $this->currController->MailTo ? $this->currController->MailTo : Email::getAdminEmail();
     $mailSubject = $this->currController->MailSubject ? $this->currController->MailSubject . ' - ' . $SQLData['Ref'] : _t('ContactPage.SUBJECT', '[web] New contact inquiry - ') . ' ' . $data['Ref'];
     $email = new Email($mailFrom, $mailTo, $mailSubject);
     $email->replyTo($SQLData['Email']);
     $email->setTemplate("ContactInquiry");
     $email->populateTemplate($SQLData);
     $email->send();
     // $this->controller->redirectBack();
     if ($email->send()) {
         $this->controller->redirect($this->controller->Link() . "success");
     } else {
         $this->controller->redirect($this->controller->Link() . "error");
     }
     return false;
 }
 /**
  * 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;
 }
 public function doSubmitContactForm($data, Form $form)
 {
     $subject = !empty($this->Subject) ? $this->Subject : 'Contact form submission';
     $email = new Email($this->getEmailFrom($data), $this->getEmailTo($data), $subject);
     $email->setTemplate('ContactForm');
     $email->populateTemplate(array('Body' => $this->buildEmailBody($data)));
     $email->send();
     Controller::redirect($this->Link("?success=1"));
 }
 /**
  * Sending mail after extension is approved.
  *
  * @param array $mailData
  */
 private function sendMailtoAuthors($mailData)
 {
     $From = $mailData['From'];
     $To = $mailData['To'];
     $Subject = $mailData['Subject'];
     $email = new Email($From, $To, $Subject);
     $email->setTemplate('ExtensionApproved');
     $email->populateTemplate($mailData);
     $email->send();
 }
Beispiel #12
0
 function SendContactForm($data, $form)
 {
     $From = $data['Email'];
     $To = $this->Mailto;
     //$To = "*****@*****.**";
     $Subject = $this->subjects[$data['Subject']];
     $email = new Email($From, $To, $Subject);
     $email->setTemplate('ContactEmail');
     $email->populateTemplate($data);
     $email->send();
     //$this->SubmitText = "Los datos se ha enviado correctamente";
     $this->redirect($this->Link("?success=1"));
 }
 /**
  * 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();
 }
 /**
  * @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();
 }
Beispiel #15
0
 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();
 }
 /**
  * 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 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();
 }
 /**
  * @param SS_HTTPRequest $req
  * @return string
  */
 public function notify(SS_HTTPRequest $req)
 {
     $notify = Config::inst()->get('FBComments', 'notify');
     $notifyFrom = Config::inst()->get('FBComments', 'notify_from');
     $notifySubject = Config::inst()->get('FBComments', 'notify_subject');
     if (!is_array($notify) || count($notify) <= 0) {
         return $this->httpError(401);
     }
     foreach ($notify as $to) {
         $email = new Email($notifyFrom, $to, $notifySubject);
         $email->setTemplate('FBCommentNotificationEmail');
         $email->populateTemplate(array('URL' => $req->requestVar('page'), 'SiteConfig' => SiteConfig::current_site_config()));
         $email->send();
     }
     return 'ok';
 }
 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 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();
 }
 public function doInvite($data, Form $form)
 {
     $data = $form->getData();
     $emails = $data['Emails']['new'];
     $sent = new DataObjectSet();
     if (!$emails) {
         $form->addErrorMessage('Emails', 'Please enter at least one person to invite.');
     }
     $time = DataObject::get_by_id('RegisterableDateTime', $data['TimeID']);
     $invite = new Email();
     $invite->setSubject(sprintf('Event Invitation For %s (%s)', $time->EventTitle(), SiteConfig::current_site_config()->Title));
     $invite->setTemplate('EventInvitationEmail');
     $invite->populateTemplate(array('Time' => $time, 'SiteConfig' => SiteConfig::current_site_config(), 'Link' => Director::absoluteURL($time->Link())));
     $count = count($emails['Name']);
     for ($i = 0; $i < $count; $i++) {
         $name = trim($emails['Name'][$i]);
         $email = trim($emails['Email'][$i]);
         if (!$name || !$email) {
             continue;
         }
         $regod = DataObject::get_one('EventRegistration', sprintf('"Email" = \'%s\' AND "TimeID" = \'%d\'', Convert::raw2sql($email), $time->ID));
         if ($regod) {
             $sent->push(new ArrayData(array('Name' => $name, 'Email' => $email, 'Sent' => false, 'Reason' => 'Already registered')));
             continue;
         }
         $invited = DataObject::get_one('EventInvitation', sprintf('"Email" = \'%s\' AND "TimeID" = \'%d\'', Convert::raw2sql($email), $time->ID));
         if ($invited) {
             $sent->push(new ArrayData(array('Name' => $name, 'Email' => $email, 'Sent' => false, 'Reason' => 'Already invited')));
             continue;
         }
         $invitation = new EventInvitation();
         $invitation->Name = $name;
         $invitation->Email = $email;
         $invitation->TimeID = $time->ID;
         $invitation->EventID = $time->EventID;
         $invitation->write();
         $_invite = clone $invite;
         $_invite->setTo($email);
         $_invite->populateTemplate(array('Name' => $name));
         $_invite->send();
         $sent->push(new ArrayData(array('Name' => $name, 'Email' => $email, 'Sent' => true)));
     }
     Requirements::clear();
     $controller = $this->customise(array('Result' => $sent));
     return $controller->renderWith('EventInvitationField_invite');
 }
 public function process()
 {
     $sent = 0;
     $filter = array('WorkflowStatus' => array('Active', 'Paused'), 'Definition.RemindDays:GreaterThan' => 0);
     $active = WorkflowInstance::get()->filter($filter);
     foreach ($active as $instance) {
         $edited = strtotime($instance->LastEdited);
         $days = $instance->Definition()->RemindDays;
         if ($edited + $days * 3600 * 24 > time()) {
             continue;
         }
         $email = new Email();
         $bcc = '';
         $members = $instance->getAssignedMembers();
         $target = $instance->getTarget();
         if (!$members || !count($members)) {
             continue;
         }
         $email->setSubject("Workflow Reminder: {$instance->Title}");
         $email->setBcc(implode(', ', $members->column('Email')));
         $email->setTemplate('WorkflowReminderEmail');
         $email->populateTemplate(array('Instance' => $instance, 'Link' => $target instanceof SiteTree ? "admin/show/{$target->ID}" : ''));
         $email->send();
         $sent++;
         // add a comment to the workflow if possible
         $action = $instance->CurrentAction();
         $currentComment = $action->Comment;
         $action->Comment = sprintf(_t('AdvancedWorkflow.JOB_REMINDER_COMMENT', '%s: Reminder email sent\\n\\n'), date('Y-m-d H:i:s')) . $currentComment;
         try {
             $action->write();
         } catch (Exception $ex) {
             SS_Log::log($ex, SS_Log::WARN);
         }
         $instance->LastEdited = time();
         try {
             $instance->write();
         } catch (Exception $ex) {
             SS_Log::log($ex, SS_Log::WARN);
         }
     }
     $this->currentStep = 2;
     $this->isComplete = true;
     $nextDate = date('Y-m-d H:i:s', time() + $this->repeatInterval);
     $this->queuedJobService->queueJob(new WorkflowReminderJob($this->repeatInterval), $nextDate);
 }
 /**
  * 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();
                         }
                     }
                 }
             }
         }
     }
 }
 function EmailAdmin($submission)
 {
     if (!empty($this->FromName)) {
         $FromName = $this->FromName;
     } else {
         $FromName = $this->SiteConfig()->Title . ' contact form';
     }
     $from = $FromName . ' <' . $this->FromEmail . '>';
     $to = $this->ToEmail;
     //$to = Email::setAdminEmail();
     $subject = 'A new submission has been received from ' . $FromName;
     $body = '';
     $email = new Email($from, $to, $subject, $body);
     //set template
     $email->setTemplate('AdminEmail');
     //populate template
     $email->populateTemplate($submission);
     //send mail
     $email->send();
 }
 public static function SendEmail($to, $subject, $template, $templateData = null)
 {
     // create email
     $emailFrom = Config::inst()->get('Email', 'admin_email');
     if (class_exists('SiteConfig')) {
         $config = SiteConfig::current_site_config();
         $templateData['SiteConfig'] = $config;
         if ($config->EmailFrom) {
             $emailFrom = $config->EmailFrom;
         }
     }
     if (class_exists('StyledHtmlEmail')) {
         $email = new StyledHtmlEmail($emailFrom, $to, $subject);
     } else {
         $email = new Email($emailFrom, $to, $subject);
     }
     //set template
     $email->setTemplate($template);
     // populate
     if (!$templateData) {
         $templateData = array();
     } else {
         if (is_a($templateData, 'DataObject')) {
             $ob = $templateData;
             $templateData = array();
             $templateData[get_class($ob)] = $ob;
         }
     }
     $templateData['Subject'] = $subject;
     $email->populateTemplate($templateData);
     //send mail
     try {
         $email->send();
     } catch (Exception $e) {
         $ei = new EmailIssue();
         $ei->EmailAddress = $to;
         $ei->Content = $e->getMessage();
         $ei->write();
     }
 }
 /**
  * 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);
 }
Beispiel #28
0
 function SendContactForm($data, $form)
 {
     // Create submission object
     $submission = new ContactFormSubmission();
     $submission->ContactPageID = $this->ID;
     // Save submission object into form object this function is needed so the submission values will be available from the $submission object.
     $form->saveInto($submission);
     $submission->write();
     // Set data
     $From = $this->MailFrom;
     $To = $this->MailTo;
     $Subject = 'PNRC Website Contact Message';
     $email = new Email($From, $To, $Subject);
     // Set template
     $email->setTemplate('ContactEmail');
     // Populate template
     $email->populateTemplate($data);
     // Send mail
     $email->send();
     // Return to submitted message
     $this->redirect($this->Link('?success=1#thanks'));
 }
 public function SendContactForm($data, $form)
 {
     if ($this->SubmitText) {
         $SubmitText = $this->SubmitText;
     } else {
         $SubmitText = "Your email is on it\\'s way. Thanks for contacting us!";
     }
     if (trim(strtolower($data['Spam'])) != 'hot') {
         $form->sessionMessage('Please give that spam question another try.', 'bad');
         Controller::redirectBack();
     } else {
         $From = $data['Email'];
         $To = $this->Mailto;
         $Subject = "Contact form submission from the contact form widget";
         $email = new Email($From, $To, $Subject);
         $email->setTemplate('ContactFormEmail');
         $email->populateTemplate($data);
         $email->send();
         $form->sessionMessage($SubmitText, 'success');
         Controller::redirectBack();
     }
 }
 function SendContactForm($data, $form)
 {
     //saves the question in the database
     $CustomerQuestion = new CustomerQuestion();
     $form->saveInto($CustomerQuestion);
     $CustomerQuestion->write();
     $cp = DataObject::get_one("ContactPage");
     //Sets data
     $From = $data['Email'];
     $To = $cp->Mailto;
     $Subject = _t('ContactPage.WEBSITECONTACTMESSAGE', "Website Contact message");
     $email = new Email($From, $To, $Subject);
     //set template
     $email->setTemplate('ContactEmail');
     //populate template
     $email->populateTemplate(array("CustomerQuestionID" => $CustomerQuestion->ID, "Name" => $data["Name"], "Cellphone" => $data["Cellphone"], "Email" => $data["Email"], "Question" => $data["Question"]));
     //send mail
     if ($email->send()) {
         Controller::curr()->redirect(Director::baseURL() . $this->URLSegment . "/success");
     } else {
         Controller::curr()->redirect(Director::baseURL() . $this->URLSegment . "/error");
     }
 }