1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00
php-e107/e107_admin/mailout.php

1018 lines
31 KiB
PHP
Raw Normal View History

2006-12-02 04:36:16 +00:00
<?php
/*
* e107 website system
*
2009-11-18 01:06:08 +00:00
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Administration - Site Maintenance
*
* $Source: /cvs_backup/e107_0.8/e107_admin/mailout.php,v $
2010-01-10 06:20:46 +00:00
* $Revision: 1.34 $
* $Date: 2010-01-10 06:20:31 $
2010-01-10 03:56:28 +00:00
* $Author: e107coders $
*
*/
/*
Features:
1. Additional sources of email addresses for mailouts can be provided via plugins, and can be enabled via the mailout preferences page
2. Both list of email recipients and the email are separately stored in the DB using a documented interface (allows alternative creation/mailout routines)
- see mail_manager_class.php
3. Can specify qmail in the sendmail path
$pref['mailout_enabled'][plugin_path] - array of flags determining which mailers are active
Extra mailout address handlers - these provide email addresses
------------------------------
1. The handler is called 'e_mailout.php' in the plugin directory.
2. Mailout options includes a facility to enable the individual handlers
3. Certain variables may be defined at load time to determine whether loading is exclusive or supplementary
4. Interface is implemented as a class, which must be called 'plugin_path_mailout'
5. see mailout_class.php in the handlers directory for an example (also simpler examples in newsletter and event calendar plugins)
Each mailout task class, must include a number of mandatory entry points:
show_select($allow_edit = FALSE) - in edit mode, returns text which facilitates address selection. Otherwise shows the current selection criteria
- the display is assigned to a single table cell
function returnSelectors() - returns storable representation of user-entered selection criteria
select_init() - initialise the selection mechanism
select_add() - routine pulls out email addresses etc, for caller to add to the list of addressees
select_close() - selection complete
2006-12-02 04:36:16 +00:00
*/
/*
Valid actions ($_GET['mode']):
'prefs' - Edit options
2006-12-02 04:36:16 +00:00
'makemail' - Create an email for use as a template, or to send
2008-11-14 06:01:06 +00:00
'saved' - email templates saved (was 'list')
'sent' - list emails where sending process complete (was 'mailouts')
'pending' - list emails in queue or being sent
'maildelete' - delete email whose 'handle' is in $mailID - shows confirmation page
'maildeleteconfirm' - does it
'edit' - edit email whose 'handle' is in $mailID
'detail' - show all the target recipients of a specific email
'resend' - resend failures on a specific list
'debug' - not currently used; may be useful to list other info
Valid subparameters (where required):
$_GET['m'] - id of mail info in db
$_GET['t'] - id of target info in db
*/
require_once('../class2.php');
if (!getperms('W'))
{
header('location:'.e_BASE.'index.php');
exit;
2006-12-02 04:36:16 +00:00
}
$e_sub_cat = 'mail';
2006-12-02 04:36:16 +00:00
require_once(e_HANDLER.'ren_help.php');
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_users.php');
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_mailout.php');
require_once(e_HANDLER.'userclass_class.php');
require_once(e_HANDLER.'mailout_class.php'); // Class handler for core mailout functions
require_once(e_HANDLER.'mailout_admin_class.php'); // Admin tasks handler
require_once(e_HANDLER.'mail_manager_class.php'); // Mail DB API
require_once (e_HANDLER.'message_handler.php');
$emessage = &eMessage :: getInstance();
2006-12-02 04:36:16 +00:00
$action = $e107->tp->toDB(varset($_GET['mode'],'makemail'));
$pageMode = varset($_GET['savepage'], $action); // Sometimes we need to know what brought us here - $action gets changed
$mailId = intval(varset($_GET['m'],0));
$targetId = intval(varset($_GET['t'],0));
// Create mail admin object, load all mail handlers
$mailAdmin = new mailoutAdminClass($action); // This decodes parts of the query using $_GET syntax
e107::setRegistry('_mailout_admin', $mailAdmin);
if ($mailAdmin->loadMailHandlers() == 0)
{ // No mail handlers loaded
echo 'No mail handlers loaded!!';
exit;
}
require_once(e_ADMIN.'auth.php');
2006-12-02 04:36:16 +00:00
$errors = array();
2006-12-02 04:36:16 +00:00
$subAction = '';
$midAction = '';
$fromHold = FALSE;
2006-12-02 04:36:16 +00:00
if (isset($_POST['mailaction']))
{
if (is_array($_POST['mailaction']))
{
foreach ($_POST['mailaction'] as $k => $v)
{
if ($v) // Look for non-empty action
{
$mailId = $k;
$action = $v;
break;
}
}
}
}
2006-12-02 04:36:16 +00:00
if (isset($_POST['targetaction']))
{
if (is_array($_POST['targetaction']))
{
foreach ($_POST['targetaction'] as $k => $v)
{
if ($v) // Look for non-empty action
{
$targetId = $k;
$action = $v;
break;
}
}
}
}
//echo "Action: {$action} MailId: {$mailId} Target: {$targetId}<br />";
// ----------------- Actions ------------------->
switch ($action)
{
case 'prefs' :
if (getperms('0'))
{
if (isset($_POST['testemail']))
{ // Send test email - uses standard 'single email' handler
if(trim($_POST['testaddress']) == '')
{
$emessage->add(LAN_MAILOUT_19, E_MESSAGE_ERROR);
$subAction = 'error';
}
else
{
$mailheader_e107id = USERID;
require_once(e_HANDLER.'mail.php');
$add = ($pref['mailer']) ? " (".strtoupper($pref['mailer']).")" : ' (PHP)';
$sendto = trim($_POST['testaddress']);
if (!sendemail($sendto, LAN_MAILOUT_113." ".SITENAME.$add, LAN_MAILOUT_114,LAN_MAILOUT_189))
{
$emessage->add(($pref['mailer'] == 'smtp') ? LAN_MAILOUT_67 : LAN_MAILOUT_106, E_MESSAGE_ERROR);
}
else
{
$emessage->add(LAN_MAILOUT_81. ' ('.$sendto.')', E_MESSAGE_SUCCESS);
$admin_log->log_event('MAIL_01',$sendto,E_LOG_INFORMATIVE,'');
}
}
}
elseif (isset($_POST['updateprefs']))
{
saveMailPrefs($emessage);
}
}
break;
2006-12-02 04:36:16 +00:00
case 'mailcopy' : // Copy existing email and go to edit screen
if (isset($_POST['mailaction']))
{
$action = 'makemail';
$mailData = $mailAdmin->retrieveEmail($mailId);
if ($mailData === FALSE)
{
$emessage->add(LAN_MAILOUT_164.':'.$mailId, E_MESSAGE_ERROR);
break;
}
unset($mailData['mail_source_id']);
}
break;
case 'mailedit' : // Edit existing mail
if (isset($_POST['mailaction']))
{
$action = 'makemail';
$mailData = $mailAdmin->retrieveEmail($mailId);
if ($mailData === FALSE)
{
$emessage->add(LAN_MAILOUT_164.':'.$mailId, E_MESSAGE_ERROR);
break;
}
}
break;
2006-12-02 04:36:16 +00:00
case 'makemail' :
$newMail = TRUE;
2010-01-10 06:20:46 +00:00
if (isset($_POST['save_email']))
{
$subAction = 'new';
}
elseif (isset($_POST['update_email']))
{
$subAction = 'update';
$newMail = FALSE;
}
elseif (isset($_POST['send_email']))
{ // Send bulk email
$subAction = 'send';
}
if ($subAction != '')
{
$mailData = $mailAdmin->parseEmailPost($newMail);
$errors = $mailAdmin->checkEmailPost($mailData, $subAction == 'send'); // Full check if sending email
if ($errors !== TRUE)
{
$subAction = 'error';
break;
}
$mailData['mail_selectors'] = $mailAdmin->getAllSelectors(); // Add in the selection criteria
}
2006-12-02 04:36:16 +00:00
// That's the checking over - now do something useful!
switch ($subAction)
{
case 'send' : // This actually creates the list of recipients in the display routine
$action = 'marksend';
break;
case 'new' :
// TODO: Check all fields created - maybe
$mailData['mail_content_status'] = MAIL_STATUS_SAVED;
$mailData['mail_create_app'] = 'core';
$result = $mailAdmin->saveEmail($mailData, TRUE);
if (is_numeric($result))
{
$mailData['mail_source_id'] = $result;
$emessage->add(LAN_MAILOUT_145, E_MESSAGE_SUCCESS);
}
else
{
$emessage->add(LAN_MAILOUT_146, E_MESSAGE_ERROR);
}
break;
case 'update' :
$mailData['mail_content_status'] = MAIL_STATUS_SAVED;
$result = $mailAdmin->saveEmail($mailData, FALSE);
if (is_numeric($result))
{
$mailData['mail_source_id'] = $result;
$emessage->add(LAN_MAILOUT_147, E_MESSAGE_SUCCESS);
}
else
{
$emessage->add(LAN_MAILOUT_146, E_MESSAGE_ERROR);
}
break;
}
break;
2009-11-16 20:40:39 +00:00
case 'mailhold' :
$action = 'held';
if ($mailAdmin->holdEmail($mailId))
{
$emessage->add(str_replace('--ID--', $mailId, LAN_MAILOUT_229), E_MESSAGE_SUCCESS);
}
else
{
$errors[] = str_replace('--ID--', $mailId, LAN_MAILOUT_230);
}
2009-11-16 20:40:39 +00:00
break;
case 'mailcancel' :
$action = $pageMode; // Want to return to some other page
if ($mailAdmin->cancelEmail($mailId))
{
$emessage->add(str_replace('--ID--', $mailId, LAN_MAILOUT_220), E_MESSAGE_SUCCESS);
}
else
{
$errors[] = str_replace('--ID--', $mailId, LAN_MAILOUT_221);
2006-12-02 04:36:16 +00:00
}
break;
case 'maildelete' :
break;
2006-12-02 04:36:16 +00:00
case 'marksend' : // Actually do something with an email and list of recipients - entry from email confirm page
$action = 'saved';
if (isset($_POST['email_cancel'])) // 'Cancel' in this context means 'delete' - don't want it any more
{
$midAction = 'midDeleteEmail';
}
elseif (isset($_POST['email_hold']))
{
if ($mailAdmin->activateEmail($mailId, TRUE))
{
$emessage->add(str_replace('--ID--', $mailId, LAN_MAILOUT_187), E_MESSAGE_SUCCESS);
}
else
{
$errors[] = str_replace('--ID--', $mailId, LAN_MAILOUT_166);
}
$action = 'held';
}
elseif (isset($_POST['email_send']))
{
$midAction = 'midMoveToSend';
$action = 'pending';
}
break;
case 'mailsendnow' : // Send mail previously on 'held' list. Need to give opportunity to change time/date etc
// $midAction = 'midMoveToSend';
// $action = 'pending';
$action = 'marksend'; // This shows the email details for confirmation
$fromHold = TRUE;
$mailData['mail_source_id'] = $mailId;
break;
case 'maildeleteconfirm' :
$action = $pageMode; // Want to return to some other page
$midAction = 'midDeleteEmail';
if (!isset($_POST['mailIDConf']) || (intval($_POST['mailIDConf']) != $mailId))
{
$errors[] = str_replace(array('--ID--', '--CHECK--'), array($mailId, intval($_POST['mailIDConf'])), LAN_MAILOUT_174);
break;
}
break;
2006-12-02 04:36:16 +00:00
case 'mailonedelete' :
case 'debug' :
$emessage->add('Not implemented yet', E_MESSAGE_ERROR);
break;
2006-12-02 04:36:16 +00:00
case 'mailtargets' :
$action = 'recipients';
// Intentional fall-through
case 'recipients' :
case 'saved' : // Show template emails - probably no actions
case 'sent' :
case 'pending' :
case 'held' :
if (isset($_POST['etrigger_ecolumns']))
{
$mailAdmin->mailbodySaveColumnPref($action);
}
break;
2006-12-02 04:36:16 +00:00
case 'maint' : // Perform any maintenance actions required
if (isset($_POST['email_dross']))
if ($mailAdmin->dbTidy()) // Admin logging done in this routine
{
$emessage->add(LAN_MAILOUT_184, E_MESSAGE_SUCCESS);
}
else
{
$errors[] = LAN_MAILOUT_183;
}
break;
2006-12-02 04:36:16 +00:00
default :
$emessage->add('Code malfunction 23! ('.$action.')', E_MESSAGE_ERROR);
$e107->ns->tablerender(LAN_MAILOUT_97, $emessage->render());
exit; // Could be a hack attempt
} // switch($action) - end of 'executive' tasks
2006-12-02 04:36:16 +00:00
// ------------------------ Intermediate actions ---------------------------
// (These have more than one route to trigger them)
switch ($midAction)
{
case 'midDeleteEmail' :
// $emessage->add($pageMode.': Would delete here: '.$mailId, E_MESSAGE_SUCCESS);
// break; // Delete this
$result = $mailAdmin->deleteEmail($mailId, 'all');
$admin_log->log_event('MAIL_04','ID: '.$mailId,E_LOG_INFORMATIVE,'');
if (($result === FALSE) || !is_array($result))
{
$errors[] = str_replace('--ID--', $mailId, LAN_MAILOUT_166);
}
else
{
if (isset($result['content']))
{
if ($result['content'] === FALSE)
{
$errors[] = str_replace('--ID--', $mailId, LAN_MAILOUT_167);
}
else
{
$emessage->add(str_replace('--ID--', $mailId, LAN_MAILOUT_167), E_MESSAGE_SUCCESS);
}
}
if (isset($result['recipients']))
{
if ($result['recipients'] === FALSE)
{
$errors[] = str_replace('--ID--', $mailId, LAN_MAILOUT_169);
}
else
{
$emessage->add(str_replace(array('--ID--', '--NUM--'), array($mailId, $result['recipients']), LAN_MAILOUT_170), E_MESSAGE_SUCCESS);
}
}
}
break;
case 'midMoveToSend' :
$notify = isset($_POST['mail_notify_complete']) ? 3 : 2;
$first = 0;
$last = 0; // Set defaults for earliest and latest send times.
// TODO: Save these fields
if (isset($_POST['mail_earliest_time']))
{
$first = e107::getDateConvert()->decodeDateTime($_POST['mail_earliest_time'], 'datetime', CORE_DATE_ORDER, FALSE);
}
if (isset($_POST['mail_latest_time']))
{
$last = e107::getDateConvert()->decodeDateTime($_POST['mail_earliest_time'], 'datetime', CORE_DATE_ORDER, TRUE);
}
if ($mailAdmin->activateEmail($mailId, FALSE, $notify, $first, $last))
{
$emessage->add(LAN_MAILOUT_185, E_MESSAGE_SUCCESS);
$admin_log->log_event('MAIL_06','ID: '.$mailId,E_LOG_INFORMATIVE,'');
}
else
{
$errors[] = str_replace('--ID--', $mailId, LAN_MAILOUT_188);
}
break;
}
2006-12-02 04:36:16 +00:00
// --------------------- Display errors and results ------------------------
if (is_array($errors) && (count($errors) > 0))
{
foreach ($errors as $e)
{
$emessage->add($e, E_MESSAGE_ERROR);
}
unset($errors);
}
if ($emessage->hasMessage())
{
2010-01-10 03:56:28 +00:00
$ns->tablerender(LAN_MAILOUT_97, $emessage->render());
}
2006-12-02 04:36:16 +00:00
// ---------------------- Display required page ----------------------------
// At this point $action determines which page display is required - one of a
// fairly limited number of choices
$mailAdmin->newMode($action);
//echo "Action: {$action} MailId: {$mailId} Target: {$targetId}<br />";
2006-12-02 04:36:16 +00:00
switch ($action)
{
case 'prefs' :
if (getperms('0'))
{
show_prefs($mailAdmin);
}
break;
2006-12-02 04:36:16 +00:00
case 'maint' :
if (getperms('0'))
{
show_maint(FALSE);
}
break;
case 'debug' :
if (getperms('0'))
{
show_maint(TRUE);
}
break;
2006-12-02 04:36:16 +00:00
case 'saved' : // Show template emails
case 'sent' :
case 'pending' :
case 'held' :
$mailAdmin->showEmailList($action, -1, -1);
break;
2006-12-02 04:36:16 +00:00
case 'maildelete' : // NOTE:: need to set previous page in form
$mailAdmin->showDeleteConfirm($mailId, $pageMode);
break;
2006-12-02 04:36:16 +00:00
case 'marksend' : // Show the send confirmation page
$mailAdmin->sendEmailCircular($mailData, $fromHold);
break;
2006-12-02 04:36:16 +00:00
case 'recipients' :
$mailAdmin->showmailRecipients($mailId, $action);
break;
case 'makemail' :
default :
if (!is_array($mailData))
{
$mailData = array(); // Empty array just in case
}
$mailAdmin->show_mailform($mailData);
break;
}
2006-12-02 04:36:16 +00:00
require_once(e_ADMIN."footer.php");
2006-12-02 04:36:16 +00:00
// Update Preferences. (security handled elsewhere)
function saveMailPrefs(&$emessage)
{
global $pref;
$e107 = e107::getInstance();
$bounceOpts = array('none' => LAN_MAILOUT_232, 'auto' => LAN_MAILOUT_233, 'mail' => LAN_MAILOUT_234);
unset($temp);
2009-09-03 19:32:33 +00:00
if (!in_array($_POST['mailer'], array('smtp', 'sendmail', 'php'))) $_POST['mailer'] = 'php';
$temp['mailer'] = $_POST['mailer'];
// Allow qmail as an option as well - works much as sendmail
2009-09-03 19:32:33 +00:00
if ((strpos($_POST['sendmail'],'sendmail') !== FALSE) || (strpos($_POST['sendmail'],'qmail') !== FALSE)) $temp['sendmail'] = $e107->tp->toDB($_POST['sendmail']);
$temp['smtp_server'] = $e107->tp->toDB($_POST['smtp_server']);
$temp['smtp_username'] = $e107->tp->toDB($_POST['smtp_username']);
$temp['smtp_password'] = $e107->tp->toDB($_POST['smtp_password']);
$smtp_opts = array();
switch (trim($_POST['smtp_options']))
{
case 'smtp_ssl' :
$smtp_opts[] = 'secure=SSL';
break;
case 'smtp_tls' :
$smtp_opts[] = 'secure=TLS';
break;
case 'smtp_pop3auth' :
$smtp_opts[] = 'pop3auth';
break;
}
if (varsettrue($_POST['smtp_keepalive'])) $smtp_opts[] = 'keepalive';
if (varsettrue($_POST['smtp_useVERP'])) $smtp_opts[] = 'useVERP';
$temp['smtp_options'] = implode(',',$smtp_opts);
$temp['mail_sendstyle'] = $e107->tp->toDB($_POST['mail_sendstyle']);
$temp['mail_pause'] = intval($_POST['mail_pause']);
$temp['mail_pausetime'] = intval($_POST['mail_pausetime']);
$temp['mail_workpertick'] = intval($_POST['mail_workpertick']);
$temp['mail_workpertick'] = min($temp['mail_workpertick'],1000);
$temp['mail_bounce'] = isset($bounceOpts[$_POST['mail_bounce']]) ? $_POST['mail_bounce'] : 'none';
switch ($temp['mail_bounce'])
{
case 'none' :
$temp['mail_bounce_email'] = '';
break;
case 'auto' :
$temp['mail_bounce_email'] = $e107->tp->toDB($_POST['mail_bounce_email2']);
break;
case 'mail' :
$temp['mail_bounce_email'] = $e107->tp->toDB($_POST['mail_bounce_email']);
$temp['mail_bounce_auto'] = intval($_POST['mail_bounce_auto']);
break;
}
2009-09-03 19:32:33 +00:00
$temp['mail_bounce_pop3'] = $e107->tp->toDB($_POST['mail_bounce_pop3']);
$temp['mail_bounce_user'] = $e107->tp->toDB($_POST['mail_bounce_user']);
$temp['mail_bounce_pass'] = $e107->tp->toDB($_POST['mail_bounce_pass']);
$temp['mail_bounce_type'] = $e107->tp->toDB($_POST['mail_bounce_type']);
$temp['mail_bounce_delete'] = intval($_POST['mail_bounce_delete']);
2006-12-02 04:36:16 +00:00
$temp['mailout_enabled'] = implode(',',$_POST['mail_mailer_enabled']);
$temp['mail_log_options'] = intval($_POST['mail_log_option']).','.intval($_POST['mail_log_email']);
if ($e107->admin_log->logArrayDiffs($temp, $pref, 'MAIL_03'))
{
save_prefs(); // Only save if changes - generates its own message
// $emessage->add(LAN_SETSAVED, E_MESSAGE_SUCCESS);
}
else
{
$emessage->add(LAN_NO_CHANGE, E_MESSAGE_INFO);
}
2006-12-02 04:36:16 +00:00
}
//----------------------------------------------------
// MAILER OPTIONS
//----------------------------------------------------
2006-12-02 04:36:16 +00:00
function show_prefs($mailAdmin)
{
2009-09-03 19:32:33 +00:00
global $pref;
$e107 = e107::getInstance();
$frm = e107::getForm();
$mes = e107::getMessage();
2006-12-02 04:36:16 +00:00
e107::getCache()->CachePageMD5 = '_';
$lastload = e107::getCache()->retrieve('emailLastBounce',FALSE,TRUE,TRUE);
$lastBounce = round((time() - $lastload) / 60);
$lastBounceText = ($lastBounce > 1256474) ? "<b>Never</b>" : "<b>".$lastBounce . " minutes </b>ago.";
2009-09-03 19:32:33 +00:00
$text = "
<form method='post' action='".e_SELF."?".e_QUERY."' id='mailsettingsform'>
<div id='mail'>
<table cellpadding='0' cellspacing='0' class='adminform'>
<colgroup span='2'>
<col class='col-label' />
<col class='col-control' />
2009-09-03 19:32:33 +00:00
</colgroup>
<tr>
<td>".LAN_MAILOUT_110."<br /></td>
<td>".$frm->admin_button(testemail, LAN_MAILOUT_112)."&nbsp;
<input name='testaddress' class='tbox' type='text' size='40' maxlength='80' value=\"".(varset($_POST['testaddress']) ? $_POST['testaddress'] : USEREMAIL)."\" />
</td>
2009-09-03 19:32:33 +00:00
</tr>
<tr>
<td style='vertical-align:top'>".LAN_MAILOUT_115."<br /></td>
<td>
2009-09-03 19:32:33 +00:00
<select class='tbox' name='mailer' onchange='disp(this.value)'>\n";
$mailers = array('php','smtp','sendmail');
foreach($mailers as $opt)
{
$sel = ($pref['mailer'] == $opt) ? "selected='selected'" : "";
$text .= "<option value='{$opt}' {$sel}>{$opt}</option>\n";
}
$text .="</select> <span class='field-help'>".LAN_MAILOUT_116."</span><br />";
2006-12-02 04:36:16 +00:00
// SMTP. -------------->
$smtp_opts = explode(',',varset($pref['smtp_options'],''));
$smtpdisp = ($pref['mailer'] != 'smtp') ? "style='display:none;'" : '';
$text .= "<div id='smtp' {$smtpdisp}>
<table style='margin-right:auto;margin-left:0px;border:0px'>
<colgroup span='2'>
<col class='col-label' />
<col class='col-control' />
</colgroup>
";
$text .= "
<tr>
<td>".LAN_MAILOUT_87.":&nbsp;&nbsp;</td>
<td>
2009-09-03 19:32:33 +00:00
<input class='tbox' type='text' name='smtp_server' size='40' value='".$pref['smtp_server']."' maxlength='50' />
</td>
</tr>
2006-12-02 04:36:16 +00:00
2009-09-03 19:32:33 +00:00
<tr>
<td>".LAN_MAILOUT_88.":&nbsp;(".LAN_OPTIONAL.")&nbsp;&nbsp;</td>
<td style='width:50%;' >
2009-09-03 19:32:33 +00:00
<input class='tbox' type='text' name='smtp_username' size='40' value=\"".$pref['smtp_username']."\" maxlength='50' />
</td>
</tr>
2006-12-02 04:36:16 +00:00
2009-09-03 19:32:33 +00:00
<tr>
<td>".LAN_MAILOUT_89.":&nbsp;(".LAN_OPTIONAL.")&nbsp;&nbsp;</td>
<td>
2009-09-03 19:32:33 +00:00
<input class='tbox' type='password' name='smtp_password' size='40' value='".$pref['smtp_password']."' maxlength='50' />
</td>
</tr>
2006-12-02 04:36:16 +00:00
2009-09-03 19:32:33 +00:00
<tr>
<td>".LAN_MAILOUT_90."</td><td>
2009-09-03 19:32:33 +00:00
<select class='tbox' name='smtp_options'>\n
<option value=''>".LAN_MAILOUT_96."</option>\n";
$selected = (in_array('secure=SSL',$smtp_opts) ? " selected='selected'" : '');
$text .= "<option value='smtp_ssl'{$selected}>".LAN_MAILOUT_92."</option>\n";
$selected = (in_array('secure=TLS',$smtp_opts) ? " selected='selected'" : '');
$text .= "<option value='smtp_tls'{$selected}>".LAN_MAILOUT_93."</option>\n";
$selected = (in_array('pop3auth',$smtp_opts) ? " selected='selected'" : '');
$text .= "<option value='smtp_pop3auth'{$selected}>".LAN_MAILOUT_91."</option>\n";
$text .= "</select>\n<br />".LAN_MAILOUT_94."</td></tr>";
$text .= "<tr>
<td>".LAN_MAILOUT_57."</td><td>
2009-09-03 19:32:33 +00:00
";
$checked = (varsettrue($pref['smtp_keepalive']) ) ? "checked='checked'" : "";
2006-12-02 04:36:16 +00:00
$text .= "<input type='checkbox' name='smtp_keepalive' value='1' {$checked} />
2009-09-03 19:32:33 +00:00
</td>
</tr>";
2006-12-02 04:36:16 +00:00
$checked = (in_array('useVERP',$smtp_opts) ? "checked='checked'" : "");
$text .= "<tr>
<td>".LAN_MAILOUT_95."</td><td>
<input type='checkbox' name='smtp_useVERP' value='1' {$checked} />
2009-09-03 19:32:33 +00:00
</td>
</tr>
</table></div>";
2006-12-02 04:36:16 +00:00
// Sendmail. -------------->
$senddisp = ($pref['mailer'] != 'sendmail') ? "style='display:none;'" : "";
$text .= "<div id='sendmail' {$senddisp}><table style='margin-right:0px;margin-left:auto;border:0px'>";
2006-12-02 04:36:16 +00:00
$text .= "
<tr>
<td>".LAN_MAILOUT_20.":&nbsp;&nbsp;</td>
<td>
2006-12-02 04:36:16 +00:00
<input class='tbox' type='text' name='sendmail' size='60' value=\"".(!$pref['sendmail'] ? "/usr/sbin/sendmail -t -i -r ".$pref['siteadminemail'] : $pref['sendmail'])."\" maxlength='80' />
</td>
</tr>
</table></div>";
2006-12-02 04:36:16 +00:00
$text .="</td>
</tr>
<tr>
<td>".LAN_MAILOUT_222."</td>
<td>";
$text .= $mailAdmin->sendStyleSelect(varset($pref['mail_sendstyle'], 'textonly'), 'mail_sendstyle');
$text .=
"<span class='field-help'>".LAN_MAILOUT_223."</span>
</td>
</tr>\n
2006-12-02 04:36:16 +00:00
<tr>
<td>".LAN_MAILOUT_25."</td>
<td> ".LAN_MAILOUT_26."
<input class='tbox' size='3' type='text' name='mail_pause' value='".$pref['mail_pause']."' /> ".LAN_MAILOUT_27.
"<input class='tbox' size='3' type='text' name='mail_pausetime' value='".$pref['mail_pausetime']."' /> ".LAN_MAILOUT_29.".<br />
<span class='field-help'>".LAN_MAILOUT_30."</span>
2006-12-02 04:36:16 +00:00
</td>
</tr>\n
<tr>
<td>".LAN_MAILOUT_156."</td>
<td><input class='tbox' size='3' type='text' name='mail_workpertick' value='".varset($pref['mail_workpertick'],5)."' />
<span class='field-help'>".LAN_MAILOUT_157."</span>
</td>
</tr>\n";
if (isset($pref['e_mailout_list']))
{ // Allow selection of email address sources
$text .= "<tr>
<td>".LAN_MAILOUT_77."</td>
<td>
";
$mail_enable = explode(',',$pref['mailout_enabled']);
foreach ($pref['e_mailout_list'] as $mailer => $v) {
$check = (in_array($mailer,$mail_enable)) ? "checked='checked'" : "";
$text .= "&nbsp;<input type='checkbox' name='mail_mailer_enabled[]' value='{$mailer}' {$check} /> {$mailer}<br />";
}
$text .= "</td></tr>\n";
}
2006-12-02 04:36:16 +00:00
list($mail_log_option,$mail_log_email) = explode(',',varset($pref['mail_log_options'],'0,0'));
$check = ($mail_log_email == 1) ? " checked='checked'" : "";
$text .= "<tr>
<td>".LAN_MAILOUT_72."</td>
<td>
<select class='tbox' name='mail_log_option'>\n
<option value='0'".(($mail_log_option==0) ? " selected='selected'" : "").">".LAN_MAILOUT_73."</option>\n
<option value='1'".(($mail_log_option==1) ? " selected='selected'" : "").">".LAN_MAILOUT_74."</option>\n
<option value='2'".(($mail_log_option==2) ? " selected='selected'" : "").">".LAN_MAILOUT_75."</option>\n
<option value='3'".(($mail_log_option==3) ? " selected='selected'" : "").">".LAN_MAILOUT_119."</option>\n
</select>\n
<input type='checkbox' name='mail_log_email' value='1' {$check} />".LAN_MAILOUT_76.
"</td>
</tr>\n";
2006-12-02 04:36:16 +00:00
$text .= "</table>
<fieldset id='core-mail-prefs-bounce'>
<legend>".LAN_MAILOUT_31."</legend>
<table cellpadding='0' cellspacing='0' class='adminedit'>
<colgroup span='2'>
<col class='col-label' />
<col class='col-control' />
</colgroup>
<tbody>
<tr>
<td>".LAN_MAILOUT_231."</td><td>";
// bounce divs = mail_bounce_none, mail_bounce_auto, mail_bounce_mail
$autoDisp = ($pref['mail_bounce'] != 'auto') ? "style='display:none;'" : "";
$autoMail = ($pref['mail_bounce'] != 'mail') ? "style='display:none;'" : "";
$bounceOpts = array('none' => LAN_MAILOUT_232, 'auto' => LAN_MAILOUT_233, 'mail' => LAN_MAILOUT_234);
$text .= "<select name='mail_bounce' class='tbox' onchange='bouncedisp(this.value)'>\n<option value=''>&nbsp;</option>\n";
foreach ($bounceOpts as $k => $v)
{
$selected = ($pref['mail_bounce'] == $k) ? " selected='selected'" : '';
$text .= "<option value='{$k}'{$selected}>{$v}</option>\n";
}
$text .= "</select>\n</td>
</tr></tbody></table>
<table cellpadding='0' cellspacing='0' class='adminedit' id='mail_bounce_auto' {$autoDisp}>
<colgroup span='2'>
<col class='col-label' />
<col class='col-control' />
</colgroup>
<tbody>
<tr><td>".LAN_MAILOUT_32."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_email2' value=\"".$pref['mail_bounce_email']."\" /></td></tr>
<tr>
<td>".LAN_MAILOUT_233."</td><td><b>".(e_DOCROOT ? substr(e_DOCROOT, 0, -1) : '/').e_HANDLER_ABS."bounce_handler.php</b>";
if(!is_readable(e_HANDLER.'bounce_handler.php'))
2009-10-26 01:23:19 +00:00
{
$text .= "<br /><span class='required'>".LAN_MAILOUT_161."</span>";
2009-10-26 01:23:19 +00:00
}
elseif(!is_executable(e_HANDLER.'bounce_handler.php')) // Seems to give wrong answers on Windoze
{
$text .= "<br /><span class='required'>".LAN_MAILOUT_162."</span>";
}
$text .= "<br /><span class='field-help'>".LAN_MAILOUT_235."</span></td></tr>
<tr><td>".LAN_MAILOUT_236."</td><td>".$lastBounceText."</td></tr>
</tbody></table>";
// Parameters for mail-account based bounce processing
$text .= "
<table cellpadding='0' cellspacing='0' class='adminedit' id='mail_bounce_mail' {$autoMail}>
<colgroup span='2'>
<col class='col-label' />
<col class='col-control' />
</colgroup>
<tbody>
<tr><td>".LAN_MAILOUT_32."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_email' value=\"".$pref['mail_bounce_email']."\" /></td></tr>
<tr><td>".LAN_MAILOUT_33."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_pop3' value=\"".$pref['mail_bounce_pop3']."\" /></td></tr>
<tr><td>".LAN_MAILOUT_34."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_user' value=\"".$pref['mail_bounce_user']."\" /></td></tr>
<tr><td>".LAN_MAILOUT_35."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_pass' value=\"".$pref['mail_bounce_pass']."\" /></td></tr>
<tr><td>".LAN_MAILOUT_120."</td><td><select class='tbox' name='mail_bounce_type'>\n
<option value=''>&nbsp;</option>\n
<option value='pop3'".(($pref['mail_bounce_type']=='pop3') ? " selected='selected'" : "").">".LAN_MAILOUT_121."</option>\n
<option value='pop3/notls'".(($pref['mail_bounce_type']=='pop3/notls') ? " selected='selected'" : "").">".LAN_MAILOUT_122."</option>\n
<option value='pop3/tls'".(($pref['mail_bounce_type']=='pop3/tls') ? " selected='selected'" : "").">".LAN_MAILOUT_123."</option>\n
<option value='imap'".(($pref['mail_bounce_type']=='imap') ? " selected='selected'" : "").">".LAN_MAILOUT_124."</option>\n
</select></td></tr>\n
";
$check = ($pref['mail_bounce_delete']==1) ? " checked='checked'" : "";
$text .= "<tr><td>".LAN_MAILOUT_36."</td><td><input type='checkbox' name='mail_bounce_delete' value='1' {$check} /></td></tr>";
$check = ($pref['mail_bounce_auto']==1) ? " checked='checked'" : "";
$text .= "<tr><td>".LAN_MAILOUT_245."</td><td><input type='checkbox' name='mail_bounce_auto' value='1' {$check} /><span class='field-help'>&nbsp;".LAN_MAILOUT_246."</span></td></tr>
</tbody>
</table></fieldset>
<div class='buttons-bar center'>".$frm->admin_button('updateprefs',LAN_MAILOUT_28)."</div>
2006-12-02 04:36:16 +00:00
</div></form>";
2006-12-02 04:36:16 +00:00
$caption = ADLAN_136." :: ".LAN_PREFS;
$e107->ns->tablerender($caption,$mes->render(). $text);
2006-12-02 04:36:16 +00:00
}
//-----------------------------------------------------------
// MAINTENANCE OPTIONS
//-----------------------------------------------------------
function show_maint($debug = FALSE)
{
2010-01-10 03:56:28 +00:00
$mes = e107::getMessage();
$ns = e107::getRender();
$text = "<div style='text-align:center'>";
2006-12-02 04:36:16 +00:00
$text .= "
<form action='".e_SELF."?mode=maint' id='email_maint' method='post'>
<fieldset id='email-maint'>
<table cellpadding='0' cellspacing='0' class='adminlist'>
<colgroup span='2'>
<col class='col-label' />
<col class='col-control' />
</colgroup>
<tbody>";
2006-12-02 04:36:16 +00:00
$text .= "<tr><td>".LAN_MAILOUT_182."</td><td><input class='button' type='submit' name='email_dross' value=\"".LAN_SUBMIT."\" /> <br /><span class='field-help'>".LAN_MAILOUT_252."</span></td></tr>";
$text .= "</tbody></table>\n</fieldset></form></div>";
2006-12-02 04:36:16 +00:00
2010-01-10 03:56:28 +00:00
$ns->tablerender("<div style='text-align:center'>".ADLAN_136." :: ".ADLAN_40."</div>", $mes->render().$text);
// $text .= "</table></div>";
}
2006-12-02 04:36:16 +00:00
2009-10-26 01:23:19 +00:00
2006-12-02 04:36:16 +00:00
function mailout_adminmenu()
{
$e107 = e107::getInstance();
$action = $e107->tp->toDB(varset($_GET['mode'],'makemail'));
if($action == 'mailedit')
{
$action = 'makemail';
2006-12-02 04:36:16 +00:00
}
$var['post']['text'] = LAN_MAILOUT_190;
2006-12-02 04:36:16 +00:00
$var['post']['link'] = e_SELF;
$var['post']['perm'] = 'W';
$var['saved']['text'] = LAN_MAILOUT_191; // Saved emails
$var['saved']['link'] = e_SELF.'?mode=saved';
$var['saved']['perm'] = 'W';
$var['pending']['text'] = LAN_MAILOUT_193; // Pending email runs
$var['pending']['link'] = e_SELF.'?mode=pending';
$var['pending']['perm'] = 'W';
2006-12-02 04:36:16 +00:00
$var['held']['text'] = LAN_MAILOUT_194; // Held email runs
$var['held']['link'] = e_SELF.'?mode=held';
$var['held']['perm'] = 'W';
2006-12-02 04:36:16 +00:00
$var['sent']['text'] = LAN_MAILOUT_192; // Completed email runs
$var['sent']['link'] = e_SELF.'?mode=sent';
$var['sent']['perm'] = 'W';
2006-12-02 04:36:16 +00:00
if(getperms("0"))
{
$var['prefs']['text'] = LAN_PREFS;
$var['prefs']['link'] = e_SELF.'?mode=prefs';
$var['prefs']['perm'] = '0';
2006-12-02 04:36:16 +00:00
$var['maint']['text'] = ADLAN_40;
$var['maint']['link'] = e_SELF.'?mode=maint';
$var['maint']['perm'] = '0';
}
show_admin_menu(LAN_MAILOUT_15, $action, $var);
2006-12-02 04:36:16 +00:00
}
function headerjs()
{
$text = "
<script type='text/javascript'>
function disp(type)
{
if(type == 'smtp')
{
2006-12-02 04:36:16 +00:00
document.getElementById('smtp').style.display = '';
document.getElementById('sendmail').style.display = 'none';
return;
}
if(type =='sendmail')
{
2006-12-02 04:36:16 +00:00
document.getElementById('smtp').style.display = 'none';
document.getElementById('sendmail').style.display = '';
return;
}
document.getElementById('smtp').style.display = 'none';
document.getElementById('sendmail').style.display = 'none';
}
function bouncedisp(type)
{
if(type == 'auto')
{
document.getElementById('mail_bounce_auto').style.display = '';
document.getElementById('mail_bounce_mail').style.display = 'none';
return;
}
if(type =='mail')
{
document.getElementById('mail_bounce_auto').style.display = 'none';
document.getElementById('mail_bounce_mail').style.display = '';
return;
}
document.getElementById('mail_bounce_auto').style.display = 'none';
document.getElementById('mail_bounce_mail').style.display = 'none';
}
2006-12-02 04:36:16 +00:00
</script>";
$mailAdmin = e107::getRegistry('_mailout_admin');
$text .= $mailAdmin->_cal->load_files();
2006-12-02 04:36:16 +00:00
return $text;
}
?>