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"; }
/** * 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(); }
/** * 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 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; $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"; }
/** * 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"); }
public function setAnalysisEmail(Analyse $analysis, $emailTo, $toName) { $content = new Content(); $message = $content->getAnalysisContent($analysis, Session::getLoggedUser()->getFirstName()); $email = new Email(); $email->setSubject("Olá " . $toName . "! Você recebeu uma análise do Bureau Inteligencia!"); $email->setMessage($message); return $email->send(null, $emailTo); }
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>"; }
/** * Tests the `setSubject` method. * * @return void * @access public */ public function testSetSubject() { $this->assertIdentical($this->_object->getSubject(), ''); // Make sure the setting was successful. $this->_object->setSubject('Test'); $this->assertIdentical($this->_object->getSubject(), 'Test'); // We only allow strings to be passed in. $this->expectException(); $this->_object->setSubject(new Object()); }
public function submit($data, $form) { $email = new Email(); $email->setTo('*****@*****.**'); $email->setFrom($data['Email']); $email->setSubject("Contact Message from {$data["Name"]}"); $messageBody = " \n <p><strong>Name:</strong> {$data['Name']}</p> \n <p><strong>Message:</strong> {$data['Message']}</p> \n "; $email->setBody($messageBody); $email->send(); return array('Content' => '<p>Thank you for your feedback.</p>', 'Form' => ''); }
public function sendEmail($data, Form $form) { $email = new Email(); $email->setTo('*****@*****.**'); $email->setFrom($data['Email']); $email->setSubject("Contact Message from {$data["Name"]}"); $messageBody = "\n <p><strong>Name:</strong> {$data['Name']}</p>\n <p><strong>Email:</strong> {$data['Email']}</p>\n <p><strong>Phone:</strong> {$data['Phone']}</p>\n <p><strong>School:</strong> {$data['School']}</p>\n <p><strong>Module:</strong> {$data['Module']}</p>\n <p><strong>Message:</strong> {$data['Message']}</p>\n "; $email->setBody($messageBody); $email->send(); return array('Content' => '<p>Thank you for your feedback.</p>', 'Form' => ''); }
public function sendPushNotification(PushNotification $notification) { $email = new Email(); $email->setFrom($this->getSetting('From')); $email->setSubject($this->getSetting('Subject')); $email->setBody($notification->Content); foreach ($notification->getRecipients() as $recipient) { $email->setTo($recipient->Email); $email->send(); } }
public function 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(); }
/** * @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(); }
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 execute(WorkflowInstance $workflow) { $members = $workflow->getAssignedMembers(); if (!$members || !count($members)) { return true; } $member = Member::currentUser(); $initiator = $workflow->Initiator(); $contextFields = $this->getContextFields($workflow->getTarget()); $memberFields = $this->getMemberFields($member); $initiatorFields = $this->getMemberFields($initiator); $variables = array(); foreach ($contextFields as $field => $val) { $variables["\$Context.{$field}"] = $val; } foreach ($memberFields as $field => $val) { $variables["\$Member.{$field}"] = $val; } foreach ($initiatorFields as $field => $val) { $variables["\$Initiator.{$field}"] = $val; } $pastActions = $workflow->Actions()->sort('Created DESC'); $variables["\$CommentHistory"] = $this->customise(array('PastActions' => $pastActions, 'Now' => SS_Datetime::now()))->renderWith('CommentHistory'); $from = str_replace(array_keys($variables), array_values($variables), $this->EmailFrom); $subject = str_replace(array_keys($variables), array_values($variables), $this->EmailSubject); if ($this->config()->whitelist_template_variables) { $item = new ArrayData(array('Initiator' => new ArrayData($initiatorFields), 'Member' => new ArrayData($memberFields), 'Context' => new ArrayData($contextFields), 'CommentHistory' => $variables["\$CommentHistory"])); } else { $item = $workflow->customise(array('Items' => $workflow->Actions(), 'Member' => $member, 'Context' => new ArrayData($contextFields), 'CommentHistory' => $variables["\$CommentHistory"])); } if ($this->ListingTemplateID) { $template = DataObject::get_by_id('ListingTemplate', $this->ListingTemplateID); $view = SSViewer::fromString($template->ItemTemplate); } else { $view = SSViewer::fromString($this->EmailTemplate); } $body = $view->process($item); foreach ($members as $member) { if ($member->Email) { $email = new Email(); $email->setTo($member->Email); $email->setSubject($subject); $email->setFrom($from); $email->setBody($body); $email->send(); } } return true; }
public function createEmail($member) { //error_log("LOG MESSAGE FROM FORUM EMAIL POST DECORATOR LINK IS ".$this->owner->AbsoluteLink()); $controller = new SubscribeController(); $email = new Email(); $from_email = $this->owner->Forum()->parent()->FromEmail; $email->setFrom($from_email); $reply_to = $this->owner->Forum()->parent()->ReplyTo; $email->addCustomHeader('Reply-To', $reply_to); $email->setTo($member->Email); $config = SiteConfig::current_site_config(); $email->setSubject($this->owner->Title . ' | ' . $config->Title . ' ' . $this->owner->Forum()->Title . ' Forum'); $email->setTemplate('Forum_SubscriberNotification'); $email->populateTemplate(array('Recipient' => $member->FirstName, 'Link' => $this->owner->Link(), 'Title' => $this->owner->Title, 'Content' => $this->owner->Content, 'Author' => $this->owner->Author()->Nickname, 'Forum' => $this->owner->Forum()->Title, 'UnsubscribeLinkFromForum' => Director::absoluteBaseURL() . $controller->Link('unsubscribe/' . $this->owner->ForumID))); $email->send(); }
/** * 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()); }
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'); }
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 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(); }
/** * 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(); }
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(); } }
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/'); }
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); }