Sends emails using HTML content generated by a View, wrapped in a standard template

/config/sprout.php Highlighted file source
Line 31: * Who to send emails to if any cronjobs fail
Line 33: $config['cron_email'] = 'root@localhost';
Line 36: * Email address for the webmaster/developer
Line 40: $config['info_email'] = 'info@example.com';
Line 43: * SMTP settings for email sending.
Line 44: * If you need more options, edit sprout/libraries/Email.php
Line 45: * The email library being used (PHPMailer) also supports other transports
Line 69: * Restrict email sending to a given set of domain names.
Line 73: $config['email_allowed_domains'] = null;
Line 75: // Only permit email to be sent to addresses at devel.example.com
Line 76: $config['email_allowed_domains'] = ['devel.example.com'];
Line 121: * Define the widget area: email
Line 123: $config['widget_areas'][4] = $area = new WidgetArea('email', 4);
Line 125: $area->setNiceName('Email');
Line 126: $area->setOrientation(WidgetArea::ORIENTATION_EMAIL);
Line 171: * Updates to pages will send an email to all operators, detailing the change made
Line 258: $config['stale_page_email'] = 'stale@example.com';
Line 260: $config['stale_page_email'] = 'stale@example.com';

/sprout/config/routes.php Highlighted file source
Line 91: $config['email_share/share'] = 'Sprout\\Controllers\\EmailShareController/share';
Line 92: $config['email_share/submit'] = 'Sprout\\Controllers\\EmailShareController/submit';
Line 93: $config['email_share/thanks'] = 'Sprout\\Controllers\\EmailShareController/thanks';

/sprout/Controllers/Admin/OperatorAdminController.php Highlighted file source
Line 21: use Sprout\Helpers\Email;
Line 22: use Sprout\Helpers\EmailText;
Line 60: 'Email' => 'email',
Line 83: $tools[] = '<li class="config"><a href="' . EmailText::adminEditUrl('operator.welcome') . '">Edit welcome message email</a></li>';
Line 183: $valid->required(['name', 'email', 'username', 'password1', 'password2']);
Line 185: $valid->check('email', 'Validity::email');
Line 186: $valid->check('email', 'Validity::length', 0, 200);
Line 238: $update_fields['email'] = $_POST['email'];
Line 255: // Send email, if message is set
Line 257: $text = EmailText::getHtml('operator.welcome', $_POST);
Line 259: $mail = new Email();
Line 260: $mail->AddAddress($_POST['email']);
Line 313: $valid->required(['username', 'name', 'email']);
Line 318: $valid->check('email', 'Validity::length', 0, 200);
Line 366: $update_fields['email'] = $_POST['email'];

/sprout/Controllers/Admin/PageAdminController.php Highlighted file source
Line 37: use Sprout\Helpers\Email;
Line 1727: // An email to the operator who is checking the revision
Line 1728: $view = new View('sprout/email/page_need_check');
Line 1735: $mail = new Email();
Line 1736: $mail->AddAddress($approval_operator['email']);
Line 1741: Notification::confirm("An email has been sent to {$approval_operator['name']}");
Line 1745: $view = new View('sprout/email/page_notify');
Line 1751: $email_sql = $operator['email'];
Line 1752: $q = "SELECT email FROM ~operators WHERE email != '' AND email != ?";
Line 1753: $res = Pdb::q($q, [$email_sql], 'pdo');
Line 1755: $mail = new Email();
Line 1756: $mail->AddAddress($row['email']);
Line 2504: $view->ops = AdminPerms::getOperatorsWithAccess('access_reportemail');
Line 2507: $view->email = $details['email'];
Line 2525: $_POST['email'] = trim($_POST['email']);
Line 2532: if ($_POST['send_to'] == 'specific' and $_POST['email'] == '') {
Line 2533: Notification::error("You didn't enter an email address");
Line 2541: $info = WorkerCtrl::start('Sprout\\Helpers\\WorkerLinkChecker', $_POST['email']);
Line 2563: $out .= '<p>An email will be sent once it is complete.</p>';
Line 2619: * Check for stale page content and send emails regarding stale pages; to be run via cron
Line 2627: $email = Kohana::config('sprout.stale_page_email');
Line 2634: op.id AS op_id, op.name AS operator, op.email
Line 2653: $op_emails = [];
Line 2655: if ($email and !preg_match('/example\.com$/', $email)) {
Line 2656: $op_emails[0] = ['email' => $email, 'pages' => []];
Line 2665: $op_emails[0]['pages'][] = [
Line 2673: if (!$row['email']) continue;
Line 2676: if (!isset($op_emails[$op])) {
Line 2677: $op_emails[$op] = [
Line 2678: 'email' => $row['email'],
Line 2684: $op_emails[$op]['pages'][] = [
Line 2692: foreach ($op_emails as $id => $details) {
Line 2693: if (empty($details['email'])) continue;
Line 2696: $msg = "Sending email to {$details['email']} about ";
Line 2700: $view = new View('sprout/email/pages_stale');
Line 2705: $mail = new Email();
Line 2708: $mail->addAddress($details['email'], $details['operator']);
Line 2710: $mail->addAddress($details['email']);

/sprout/Controllers/ContentSubscribeController.php Highlighted file source
Line 22: use Sprout\Helpers\Email;
Line 36: * Subscribers are emailed regarding new/updated content as various subscription handlers see fit
Line 56: $q = "SELECT email
Line 61: $email = Pdb::q($q, [$id, $code], 'val');
Line 67: // Fetch all of the subscriptions for this email address.
Line 68: // Codes are derived from the email address so they'll all be the same.
Line 71: WHERE code = ? AND email = ?
Line 73: $res = Pdb::q($q, [$code, $email], 'arr');
Line 113: $q = "SELECT email
Line 118: $email = Pdb::q($q, [$id, $code], 'row');
Line 130: // Fetch the IDs of all of the subscriptions for this email address.
Line 131: // Codes are derived from the email address so they'll all be the same.
Line 134: WHERE code = ? AND email = ?";
Line 135: $ids = Pdb::q($q, [$code, $email], 'col');
Line 150: * Send the content subscription emails to the users who have registered
Line 166: // Fake the subsite selection so that the subscription handlers and email sending all behaves correctly
Line 173: $q = "SELECT id, code, handler_class, handler_settings, name, email, subsite_id
Line 189: if (!isset($users[$row['email']])) {
Line 190: $users[$row['email']] = array(
Line 198: $users[$row['email']]['subs'][] = md5($row['handler_class'] . '.' . $row['handler_settings']);
Line 252: foreach ($users as $email => $deets) {
Line 275: $view = new View('sprout/email/content_subscribe');
Line 278: $view->email = $email;
Line 282: $mail = new Email();
Line 283: $mail->AddAddress($email);
Line 288: Cron::message($email . ($result ? '; success' : '; failure'));
Line 295: Cron::failure('All emails we tried to send failed; is there a server config error?');

/sprout/Controllers/DbToolsController.php Highlighted file source
Line 38: use Sprout\Helpers\Email;
Line 108: [ 'url' => 'dbtools/email', 'name' => 'Test email', 'desc' => 'Renders form to send emails' ],
Line 1635: 'email' => 'VARCHAR(150)',
Line 1782: 'email',
Line 2148: 'email',
Line 2490: $email = new View('sprout/email/testing_long');
Line 2498: // Email template
Line 2500: $view->content = $email->render();
Line 2750: * Renders form to send emails
Line 2752: public function email()
Line 2757: $data['emails'] = $op['email'];
Line 2758: $data['from'] = Kohana::config('sprout.site_email');
Line 2763: $out = '<form action="SITE/dbtools/emailSend" method="post">';
Line 2767: $out .= Form::multiline('emails', []);
Line 2770: $out .= Form::email('from');
Line 2773: $out .= Form::multiradio('msg', [], ['long' => 'Long test email - tables, headings, unicode, etc.', 'short' => 'Short simple test email']);
Line 2778: $out .= '<button class="button" type="submit">Send emails</button>';
Line 2782: $this->template('Email');
Line 2789: public function emailSend()
Line 2793: if (empty($_POST['emails'])) {
Line 2794: Url::redirect('dbtools/email');
Line 2798: $subject = "Test email containing a little bit of üńìĉȯḍē.";
Line 2799: $view = new View('sprout/email/testing_long');
Line 2804: $body = '<p>This is a test email.</p>';
Line 2808: Validity::email($_POST['from']);
Line 2811: $addresses = explode("\n", $_POST['emails']);
Line 2820: Validity::email($e);
Line 2826: $mail = new Email();
Line 2848: echo '<p>Sent email to <b>', Enc::html($e), '</b>.</p>';
Line 2858: echo '<p><a href="SITE/dbtools/email" class="button">Send more!</a></p>';
Line 2859: $this->template('Email');

/sprout/Controllers/EmailShareController.php Highlighted file source
Line 22: use Sprout\Helpers\Email;
Line 37: class EmailShareController extends Controller
Line 83: $data = @$_SESSION['email_share']['field_values'];
Line 107: $form = new View('sprout/email_share_form');
Line 109: if (!empty($_SESSION['email_share']['field_errors'])) {
Line 110: $form->errors = $_SESSION['email_share']['field_errors'];
Line 114: if (empty($_SESSION['email_share']['captcha_passed'])) {
Line 121: $page_view->controller = 'email_share';
Line 127: * Send a shared email
Line 135: $result = RateLimit::checkLimitIP('email-share-action', null, 25, 10 * 60);
Line 143: $_POST['their_email'] = trim(@$_POST['their_email']);
Line 150: $_SESSION['email_share']['field_values'] = Validator::trim($_POST);
Line 153: $valid->required(['url', 'their_name', 'their_email']);
Line 157: $valid->check('their_email', 'Validity::email');
Line 158: $valid->check('their_email', 'Validity::length', 0, 255);
Line 161: if (empty($_SESSION['email_share']['captcha_passed'])) {
Line 163: $_SESSION['email_share']['captcha_passed'] = true;
Line 170: RateLimit::logHitFailure('email-share-action');
Line 171: $_SESSION['email_share']['field_errors'] = $valid->getFieldErrors();
Line 173: Url::redirect('email_share/share');
Line 177: $view = new View('sprout/email/email_share');
Line 184: $mail = new Email();
Line 185: $mail->AddAddress($_POST['their_email']);
Line 190: RateLimit::logHitSuccess('email-share-action');
Line 192: unset($_SESSION['email_share']);
Line 194: Url::redirect ('email_share/thanks?url=' . Enc::url($_POST['url']));
Line 210: $form = new View('sprout/email_share_thanks');
Line 217: $page_view->controller_name = 'email_share';

/sprout/Controllers/PageController.php Highlighted file source
Line 25: use Sprout\Helpers\Email;
Line 170: * @param string $approval_code Code to view the revision without authentication, e.g. via emailed link.
Line 512: op.id AS op_id, op.email, op.name AS op_name
Line 539: // Send an email to the operator who requested the change
Line 541: $view = new View('sprout/email/page_approved');
Line 547: $mail = new Email();
Line 548: $mail->AddAddress($rev['email']);
Line 562: // Send an email to the operator who requested the change
Line 564: $view = new View('sprout/email/page_rejected');
Line 570: $mail = new Email();
Line 571: $mail->AddAddress($rev['email']);

/sprout/Helpers/Email.php Highlighted file source
Line 20: * Sends emails using HTML content generated by a View, wrapped in a standard template
Line 23: * $view = new View('modules/MyModule/welcome_email');
Line 26: * $mail = new Email();
Line 32: class Email extends PHPMailer
Line 39: $this->From = Kohana::config('sprout.site_email');
Line 51: $this->AllowedDomains = Kohana::config('sprout.email_allowed_domains');
Line 73: * Sets the message content to be the specified content, with the email skin around it
Line 76: * @param $content string|View The content for the email.
Line 79: * @param $template string The template to use for the outer view. The default is "skin/email".
Line 81: public function SkinnedHTML($content, $extraparams = null, $template = 'skin/email')

/sprout/Helpers/EmailText.php Highlighted file source
Line 23: class EmailText
Line 27: * Return email text HTML
Line 29: * @param string $code The email template to use
Line 37: $reg = Register::getEmailText($code);
Line 39: throw new Exception('Did not find registration for emailText with code of "' . $code . '"');
Line 43: $q = "SELECT text FROM ~email_texts WHERE name = ?";
Line 68: * Return an array of name => desc for the field definitions for a given email template
Line 73: $reg = Register::getEmailText($code);
Line 94: $reg = Register::getEmailText($code);
Line 96: throw new Exception('Did not find registration for emailText with code of "' . $code . '"');
Line 100: $q = "SELECT id FROM ~email_texts WHERE name = ?";
Line 110: $item_id = Pdb::insert('email_texts', $update_fields);
Line 113: return 'admin/edit/email_text/' . $item_id;

/sprout/Helpers/Form.php Highlighted file source
Line 51: * Form::nextFieldDetails('Email', true, 'Please enter your email address');
Line 52: * echo Form::email('email', [], ['-wrapper-class' => 'small']);
Line 233: * @param string $label Human label for the field (e.g. 'Email address'). Some HTML allowed

/sprout/Helpers/LaunchChecks.php Highlighted file source
Line 91: public static function testEmail()
Line 94: $email = Kohana::config('sprout.site_email');
Line 97: $email_domain = preg_replace('/^.*@/', '', $email);
Line 99: if ($cli_domain != $email_domain) {
Line 100: self::addResult('Site email', 'error', 'Address "' . $email . '" does not match CLI domain');
Line 102: self::addResult('Site email', 'okay', $email);

/sprout/Helpers/Register.php Highlighted file source
Line 36: private static $emailtexts = array();
Line 203: * Register an email text
Line 212: * e.g 'email/user_welcome'
Line 214: public static function emailText($code, array $field_defs, $default_html_view)
Line 216: self::$emailtexts[$code] = new EmailTextReg($field_defs, $default_html_view);
Line 220: * Get all registered email texts. Returns an array of EmailTextReg objects
Line 222: public static function getEmailTexts()
Line 224: return self::$emailtexts;
Line 228: * Get a single registered email texts. Returns an EmailTextReg object
Line 230: public static function getEmailText($code)
Line 232: return self::$emailtexts[$code];
Line 292: self::$admin_controllers['email_text'] = '\\Sprout\\Controllers\\Admin\\EmailTextAdminController';

/sprout/Helpers/SocialNetworking.php Highlighted file source
Line 186: * Get the A tag for an email share link
Line 188: public static function emailLink($class = '')
Line 190: $share_url = 'email_share/share?url=' . Enc::url(self::$url) . '&title=' . Enc::url(self::$title);
Line 198: * Output a email share button
Line 200: public static function email($icon = null)
Line 202: if (! $icon) $icon = 'SKIN/images/icon_email-white.svg';
Line 204: echo "<div class='share-link share-link--email'>";
Line 205: echo self::emailLink();
Line 206: echo "<img src=\"{$icon}\" alt=\"Email\" title=\"Email\">";

/sprout/Helpers/Spam.php Highlighted file source
Line 37: $out .= ' <p><b><label for="' . $code . '">Email address:</label></b><br><input name="_email" id="' . $code . '" value=""></p>';
Line 49: if (!empty($_POST['_email'])) return false;
Line 129: // Email addresses
Line 131: $errors['email'] = 'Cannot contain an email address';

/sprout/Helpers/Sprout.php Highlighted file source
Line 768: * Return a list of admins to send emails to.
Line 771: * The inner arrays contains the keys "name" and "email".
Line 773: public static function adminEmails()
Line 777: $ops = AdminPerms::getOperatorsWithAccess('access_reportemail');
Line 781: 'email' => $row['email'],

/sprout/Helpers/Text.php Highlighted file source
Line 259: * Converts text email addresses and anchors into links.
Line 266: // Auto link emails first to prevent problems with "www.domain.com@example.com"
Line 267: return Text::autoLinkUrls(Text::autoLinkEmails($text));
Line 302: * Converts text email addresses into links.
Line 307: public static function autoLinkEmails($text)
Line 309: // Finds all email addresses that are not part of an existing html mailto anchor
Line 316: // Replace each email with an encoded mailto

/sprout/Helpers/Validator.php Highlighted file source
Line 29: * $valid->required(['name', 'email']);
Line 32: * $valid->check('email', 'Validity::email');
Line 67: * 'email' => 'Email address for student ' . $record_num,
Line 70: * $multi_valid->required(['name', 'email']);
Line 72: * $multi_valid->check('email', 'Validity::email');

/sprout/Helpers/WorkerLinkChecker.php Highlighted file source
Line 36: public function run($email_address = null)
Line 102: $view = new View('sprout/email/link_checker');
Line 113: Worker::message("Sending reports via email");
Line 115: if ($email_address) {
Line 118: 'email' => $email_address,
Line 121: $ops = AdminPerms::getOperatorsWithAccess('access_reportemail');
Line 126: if ($row['email'] == '') continue;
Line 128: $mail = new Email();
Line 129: $mail->AddAddress($row['email']);
Line 136: Worker::message("Sent report to {$row['name']} ({$row['email']})");
Line 139: Worker::message("Sending of report to {$row['name']} ({$row['email']}) failed!");
Line 143: Worker::message("{$sent} email(s) sent successfully.");

/sprout/views/admin/link_checker.php Highlighted file source
Line 21: Form::setData(['send_to' => 'admins', 'email' => $email]);
Line 42: 'specific' => 'A specific email address'
Line 49: echo '<div class="info">There are no users specified to receive email reports. ';
Line 55: if (!$row['email']) continue;
Line 56: echo '<li>', Enc::html($row['name']), ' (', Enc::html($row['email']), ')</li>';
Line 64: <?php Form::nextFieldDetails('Email address', true); ?>
Line 65: <?= Form::text('email'); ?>
A total of 300 lines in 34 files were found