diff --git a/e107_plugins/calendar_menu/e_mailout.php b/e107_plugins/calendar_menu/e_mailout.php
new file mode 100644
index 000000000..bdf875de6
--- /dev/null
+++ b/e107_plugins/calendar_menu/e_mailout.php
@@ -0,0 +1,186 @@
+e107 = e107::getInstance();
+ if ($mailerAdminHandler == NULL)
+ {
+ global $mailAdmin;
+ $mailerAdminHandler = $mailAdmin;
+ }
+ $this->adminHandler = $mailerAdminHandler;
+ }
+
+
+ /**
+ * Return data representing the user's selection criteria as entered in the $_POST array.
+ *
+ * This is stored in the DB with a saved email. (Just return an empty string or array if this is undesirable)
+ * The returned value is passed back to selectInit() and showSelect when needed.
+ *
+ * @return string Selection data - comma-separated list of category IDs
+ */
+ public function returnSelectors()
+ {
+ $res = array();
+ foreach ($_POST['ec_category_sel'] as $k => $v)
+ {
+ $res[] = intval($v);
+ }
+ return implode(',',$res);
+ }
+
+
+ /**
+ * Called to initialise data selection routine.
+ * Needs to save any queries or other information into internal variables, do initial DB queries as appropriate.
+ * Could in principle read all addresses and buffer them for later routines, if this is more convenient
+ *
+ * @param $selectVals - array of selection criteria as returned by returnSelectors()
+ *
+ * @return Return number of records available (or 1 if unknown) on success, FALSE on failure
+ */
+ public function selectInit($selectVals = FALSE)
+ {
+ if (($selectVals === FALSE) || ($selectVals == ''))
+ {
+ return 0; // No valid selector - so no valid records
+ }
+
+ $where = array();
+ $qry = 'SELECT u.user_id, u.user_name, u.user_email, u.user_loginname, u.user_sess, u.user_lastvisit FROM `#event_subs` AS es';
+ $qry .= ' LEFT JOIN `#user` AS u ON es.`event_subid` = u.`user_id` WHERE es.`event_cat` IN (\''.$selectVals.'\') AND u.`user_id` IS NOT NULL';
+ $qry .= ' GROUP BY u.`user_id`';
+// echo "Selector query: ".$qry.'
';
+ if (!( $this->mail_count = $this->e107->sql->db_Select_gen($qry))) return FALSE;
+ $this->selectorActive = TRUE;
+ $this->mail_read = 0;
+ return $this->mail_count;
+ }
+
+
+
+ /**
+ * Return an email address to add to the recipients list. Return FALSE if no more addresses to add
+ *
+ * @return FALSE if no more addresses available; else an array:
+ * 'mail_recipient_id' - non-zero if a registered user, zero if a non-registered user. (Always non-zero from this class)
+ * 'mail_recipient_name' - user name
+ * 'mail_recipient_email' - email address to use
+ * 'mail_target_info' - array of info which might be substituted into email, usually using the codes defined by the editor.
+ * Array key is the code within '|...|', value is the string for substitution
+ */
+ public function selectAdd()
+ {
+ if (!$this->selectorActive) return FALSE;
+ if (!($row = $this->e107->sql->db_Fetch(MYSQL_ASSOC))) return FALSE;
+ $ret = array('mail_recipient_id' => $row['user_id'],
+ 'mail_recipient_name' => $row['user_name'], // Should this use realname?
+ 'mail_recipient_email' => $row['user_email'],
+ 'mail_target_info' => array(
+ 'USERID' => $row['user_id'],
+ 'DISPLAYNAME' => $row['user_name'],
+ 'SIGNUP_LINK' => $row['user_sess'],
+ 'USERNAME' => $row['user_loginname'],
+ 'USERLASTVISIT' => $row['user_lastvisit']
+ )
+ );
+ $this->mail_read++;
+ return $ret;
+ }
+
+
+ // Called once all email addresses read, to do any housekeeping needed
+ public function select_close()
+ {
+ // Nothing to do here
+ }
+
+
+ // Called to show current selection criteria, and optionally allow edit
+ //
+ //
+ /**
+ * Called to show current selection criteria, and optionally allow edit
+ *
+ * @param $allow_edit is TRUE to allow user to change the selection; FALSE to just display current settings
+ * @param $selectVals is the current selection information - in the same format as returned by returnSelectors()
+ *
+ * @return Returns HTML which is displayed in a table cell. Typically we return a complete table
+ */
+ public function showSelect($allow_edit = FALSE, $selectVals = FALSE)
+ {
+ $ret = "
+ ".$row['event_cat_name']." | |
".LAN_EC_MAIL_03." | + ".$row['event_cat_name']." |
".LAN_EC_MAIL_02.' |