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";
 }
 /**
  * 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;
 }
Beispiel #3
0
 public function changeStatus()
 {
     $status = (int) $this->request->get('status');
     $shipment = Shipment::getInstanceByID('Shipment', (int) $this->request->get('id'), true, array('Order' => 'CustomerOrder', 'ShippingAddress' => 'UserAddress'));
     $shipment->loadItems();
     $zone = $shipment->getDeliveryZone();
     $shipmentRates = $zone->getShippingRates($shipment);
     $shipment->setAvailableRates($shipmentRates);
     $history = new OrderHistory($shipment->order->get(), $this->user);
     $shipment->status->set($status);
     $shipment->save();
     $history->saveLog();
     $status = $shipment->status->get();
     $enabledStatuses = $this->config->get('EMAIL_STATUS_UPDATE_STATUSES');
     $m = array('EMAIL_STATUS_UPDATE_NEW' => Shipment::STATUS_NEW, 'EMAIL_STATUS_UPDATE_PROCESSING' => Shipment::STATUS_PROCESSING, 'EMAIL_STATUS_UPDATE_AWAITING_SHIPMENT' => Shipment::STATUS_AWAITING, 'EMAIL_STATUS_UPDATE_SHIPPED' => Shipment::STATUS_SHIPPED);
     $sendEmail = false;
     foreach ($m as $configKey => $constValue) {
         if ($status == $constValue && array_key_exists($configKey, $enabledStatuses)) {
             $sendEmail = true;
         }
     }
     if ($sendEmail || $this->config->get('EMAIL_STATUS_UPDATE')) {
         $user = $shipment->order->get()->user->get();
         $user->load();
         $email = new Email($this->application);
         $email->setUser($user);
         $email->setTemplate('order.status');
         $email->set('order', $shipment->order->get()->toArray(array('payments' => true)));
         $email->set('shipments', array($shipment->toArray()));
         $email->send();
     }
     return new JSONResponse(false, 'success');
 }
 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";
 }
 /**
  * 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;
 }
 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();
 }
 /**
  * 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 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;
     }
 }
Beispiel #10
0
 private function sendMessage(NewsletterSentMessage $sent, LiveCart $application)
 {
     $config = $application->getConfig();
     $email = new Email($application);
     $email->setTemplate('newsletter/template');
     $email->set('subject', $this->subject->get());
     $email->set('htmlMessage', $this->html->get());
     $email->set('text', $this->text->get());
     $email->set('email', $this->text->get());
     $email->setFrom($config->get('NEWSLETTER_EMAIL') ? $config->get('NEWSLETTER_EMAIL') : $config->get('MAIN_EMAIL'), $config->get('STORE_NAME'));
     if ($user = $sent->user->get()) {
         $email->setTo($user->email->get(), $user->getName());
         $email->set('email', $user->email->get());
     } else {
         if ($subscriber = $sent->subscriber->get()) {
             $email->setTo($subscriber->email->get());
             $email->set('email', $subscriber->email->get());
         }
     }
     //$sent->time->set(new ARExpressionHandle('NOW()'));
     $sent->save();
     if ($this->status->get() == self::STATUS_NOT_SENT) {
         $this->status->set(self::STATUS_PARTIALLY_SENT);
         $this->time->set(new ARExpressionHandle('NOW()'));
         $this->save();
     }
     return $email->send();
 }
 public function 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();
 }
 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;
 }
Beispiel #14
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"));
 }
 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');
 }
Beispiel #16
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();
 }
 public function EmailAuthorization()
 {
     if (!$this->Page() || !$this->Email || !$this->AccessCode) {
         //Exit if this is an incomplete record
         return false;
     }
     //@TODO Clean up the Client Info output as it's currently pretty ugly
     $email = new Email($this->Page()->FromEmailAddress, $this->Email, 'Your Access Code for ' . $this->Page()->Title);
     $email->setTemplate('AuthorizationEmail')->populateTemplate(array('ClientInfo' => $this->ClientInfo, 'Link' => $this->AbsoluteLink()));
     $email->send();
     $this->EmailSent = (string) SS_Datetime::now();
     $this->logEmailSent();
     return true;
 }
 /**
  * @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 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();
 }
 /**
  * @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 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');
 }
 /**
  * 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 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();
     }
 }
Beispiel #26
0
 function sendInvitesAction()
 {
     $this->load->model('invite');
     $this->load->model('invitation_code');
     $invites = $this->invite->get();
     foreach ($invites as $i) {
         $code = $this->invitation_code->generateSingleCode();
         require_once APPPATH . 'models/objects/email.php';
         $email = new Email();
         $email->setFrom('*****@*****.**');
         $email->setSubject('Invitation to try Readbo!');
         $email->setTemplate('invitation', array('code' => $code));
         $success = $email->send($i->email);
         if ($success) {
             $this->invite->delete(array('id' => $i->id));
         }
     }
     header('Location: /admin/');
 }
 /**
  * Register action
  * @param type $data
  * @param type $form
  * @return \SS_HTTPResponse
  */
 public function doRegister($data, $form)
 {
     $r = new EventRegistration();
     $form->saveInto($r);
     $EventDetails = Event::get()->byID($r->EventID);
     if ($EventDetails->TicketsRequired) {
         $r->AmountPaid = $r->AmountPaid / 100;
     }
     $r->write();
     $from = Email::getAdminEmail();
     $to = $r->Email;
     $bcc = $EventDetails->RSVPEmail;
     $subject = "Event Registration - " . $EventDetails->Title . " - " . date("d/m/Y H:ia");
     $body = "";
     $email = new Email($from, $to, $subject, $body, null, null, $bcc);
     $email->setTemplate('EventRegistration');
     $email->send();
     exit;
 }
 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);
 }