/**
  * 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");
 }
Exemple #3
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();
 }
Exemple #4
0
 public function sendContactForm($data, $form)
 {
     $email = new Email();
     $email->setFrom('"mSupply Contact Form" <*****@*****.**>')->setTo($this->SiteConfig()->ContactFormEmail)->setSubject('mSupply Message')->setTemplate('ContactFormEmail')->populateTemplate(new ArrayData(array('FullName' => $data['FullName'], 'Phone' => $data['Phone'], 'Email' => $data['Email'], 'Message' => $data['Message'])));
     $email->send();
     return $this->redirectback();
 }
 /**
  * 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();
 }
Exemple #6
0
 public function SendNewsletterForm($data, $form)
 {
     $email = new Email();
     $email->setFrom('"mSupply Newsletter Form" <*****@*****.**>')->setTo($this->SiteConfig()->NewsletterFormEmail)->setSubject('mSupply Newsletter Request')->setTemplate('NewsletterSignUpEmail')->populateTemplate(new ArrayData(array('Email' => $data['Email'])));
     $email->send();
     return $this->redirectback();
 }
 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>";
 }
 /**
  * Sends an email receipt to customer
  *
  * @param  CustomerOrder $order
  * @return bool
  * @todo  Make subject configurable
  * @todo  Make tempalte more generic
  */
 public function emailCustomer($order)
 {
     $subject = 'Thank you for order on ' . date('Y-m-d' . '!') . ' from website';
     $from = SS_SEND_EMAIL_FROM;
     $to = $this->Email;
     $email = new Email();
     $email->setFrom($from)->setTo($to)->setSubject($subject)->setTemplate('CustomerEmail')->populateTemplate(new ArrayData(array('Customer' => $order->Customer(), 'CartItems' => $order->OrderItems(), 'ShippingCostTotal' => $order->shippingcost(), 'CartTotal' => $order->TotalAmount)));
     // $email->populateTemplate($order);
     $email->send();
 }
 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();
     }
 }
Exemple #10
0
 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' => '');
 }
Exemple #11
0
 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');
 }
 /**
  * @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();
 }
Exemple #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();
 }
 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;
 }
 /**
  * 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();
 }
Exemple #19
0
 /**
  * Tests the `setFrom` method.
  *
  * @return void
  * @access public
  */
 public function testFrom()
 {
     $this->assertNull($this->_object->getFrom());
     $email1 = new \Postman\Library\Email\Address('*****@*****.**');
     $email2 = new \Postman\Library\Email\Address('*****@*****.**');
     /**
      * The object takes care of converting strings into their appropriate objects
      * so we should expect the *exact* same object back after this.
      */
     $this->assertIdentical($this->_object->setFrom('*****@*****.**'), $email1);
     // It should also be able to accept an `Address` object.
     $this->assertIdentical($this->_object->setFrom($email2), $email2);
     // This should fail since it's not a valid `Address` object.
     $this->expectException();
     $this->_object->setFrom(new Object());
 }
Exemple #20
0
 function testUser()
 {
     $user = User::getNewInstance('*****@*****.**');
     $user->firstName->set('test');
     $user->lastName->set('recipient');
     Swift_Connection_Fake::resetBuffer();
     $user->save();
     //var_dump(Swift_Connection_Fake::getBuffer());
     $email = new Email(self::getApplication());
     $email->setFrom('*****@*****.**', 'Unit Test');
     $email->setSubject('test');
     $email->setText('some text');
     $email->setUser($user);
     $res = $email->send();
     $this->assertTrue(strpos($email->getMessage()->getHeaders()->get('To'), $user->email->get()) !== false);
     $this->assertEqual($res, 1);
 }
 /**
  * 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();
 }
 /**
  * Email the welcome message and return to the view account page
  */
 function send_email()
 {
     // Construct an Email
     $email = new Email();
     $email->setFrom($this->conf['company']['email'], $this->conf['company']['name']);
     $email->addRecipient($this->session['welcome_email']['email']);
     $email->setSubject($this->session['welcome_email']['subject']);
     $email->setBody($this->session['welcome_email']['email_body']);
     // Send the email
     if (!$email->send()) {
         // Error delivering invoice
         throw new SWUserException("[WELCOME_EMAIL_FAILED]");
     }
     // Return to view_account with a sucess message
     $this->setMessage(array("type" => "[WELCOME_SENT]"));
     $this->gotoPage("accounts_view_account", null, "account=" . $this->get['account']->getID());
 }
Exemple #24
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/');
 }
Exemple #25
0
 function sendAjax()
 {
     $response = array();
     $comment = $this->input->post('comment');
     $email_address = $this->input->post('email');
     $name = $this->input->post('name');
     $type = $this->input->post('report_type');
     $message = $comment . "\n\n\n";
     foreach ($_SERVER as $k => $v) {
         $message .= $k . ': ' . $v . "\n";
     }
     require_once APPPATH . 'models/objects/email.php';
     $email = new Email();
     $email->setFrom($name . " <{$email_address}>");
     $email->setSubject('readbo.com - Reporting ' . $type . ' - ' . $name);
     $email->setBody($message);
     $response['success'] = $email->send('*****@*****.**');
     $this->sendToAjax($response);
 }
 /**
  * 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 execute(WorkflowInstance $workflow)
 {
     $email = new Email();
     $members = $workflow->getAssignedMembers();
     $emails = '';
     if (!$members || !count($members)) {
         return;
     }
     foreach ($members as $member) {
         if ($member->Email) {
             $emails .= "{$member->Email}, ";
         }
     }
     $context = $this->getContextFields($workflow->getTarget());
     $member = $this->getMemberFields();
     $variables = array();
     foreach ($context as $field => $val) {
         $variables["\$Context.{$field}"] = $val;
     }
     foreach ($member as $field => $val) {
         $variables["\$Member.{$field}"] = $val;
     }
     $subject = str_replace(array_keys($variables), array_values($variables), $this->EmailSubject);
     if ($this->ListingTemplateID) {
         $item = $workflow->customise(array('Items' => $workflow->Actions(), 'Member' => Member::currentUser(), 'Context' => $workflow->getTarget()));
         $template = DataObject::get_by_id('ListingTemplate', $this->ListingTemplateID);
         $view = SSViewer::fromString($template->ItemTemplate);
         $body = $view->process($item);
     } else {
         $body = str_replace(array_keys($variables), array_values($variables), $this->EmailTemplate);
     }
     $email->setSubject($subject);
     $email->setFrom($this->EmailFrom);
     $email->setBcc(substr($emails, 0, -2));
     $email->setBody($body);
     $email->send();
     return true;
 }
 /**
  * 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 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();
 }