mirror of
https://github.com/e107inc/e107.git
synced 2025-04-22 13:41:52 +02:00
Bounce-handling test option added. Correct path issue in perms notification.
This commit is contained in:
parent
e7ad72b3a2
commit
0dbb7cecdb
@ -383,7 +383,7 @@ class cron_admin_ui extends e_admin_ui
|
||||
elseif (!$active) // show instructions
|
||||
{
|
||||
$setpwd_message = $frm->open("generate")."<small>"
|
||||
.LAN_CRON_15.":</small><br /><pre style='color:black'>".rtrim($_SERVER['DOCUMENT_ROOT'], '/').e_HTTP."cron.php token=".$pref['e_cron_pwd'].' >/dev/null 2>&1';
|
||||
.LAN_CRON_15.":</small><br /><pre style='color:black'>".e_ROOT."cron.php token=".$pref['e_cron_pwd'].' >/dev/null 2>&1';
|
||||
|
||||
$setpwd_message .= "</pre><small>". LAN_CRON_16."</small>";
|
||||
if(e_DOMAIN && file_exists("/usr/local/cpanel/version"))
|
||||
|
@ -421,6 +421,10 @@ class mailout_main_ui extends e_admin_ui
|
||||
{
|
||||
$this->sendTestEmail(); // Send test email - uses standard 'single email' handler
|
||||
}
|
||||
if(!empty($_POST['send_bounce_test']))
|
||||
{
|
||||
$this->sendTestBounce();
|
||||
}
|
||||
elseif (isset($_POST['updateprefs']))
|
||||
{
|
||||
$this->saveMailPrefs($mes); // TODO check if functional, $emessage -> $mes
|
||||
@ -431,6 +435,29 @@ class mailout_main_ui extends e_admin_ui
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function sendTestBounce()
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
$pref = e107::getPref();
|
||||
|
||||
$sendto = $pref['mail_bounce_email'];
|
||||
|
||||
$eml = array('subject'=>'Test Bounce', 'body' => 'Test Bounce Email address','e107_header'=>99999999, 'extra_header' => 'X-Bounce-Test: true');
|
||||
|
||||
if(e107::getEmail()->sendEmail($sendto, 'Bounce handler', $eml))
|
||||
{
|
||||
$mes->addSuccess('Test Bounce sent to '.$sendto);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->addError('Failed Bounce email sent to '.$sendto);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function sendTestEmail()
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
@ -840,7 +867,7 @@ class mailout_main_ui extends e_admin_ui
|
||||
$lastload = e107::getCache()->retrieve('emailLastBounce',FALSE,TRUE,TRUE);
|
||||
$lastBounce = round((time() - $lastload) / 60);
|
||||
|
||||
$lastBounceText = ($lastBounce > 1256474) ? "<b>Never</b>" : "<b>".$lastBounce . " minutes </b>ago.";
|
||||
$lastBounceText = ($lastBounce > 1256474) ? "<span class='label label-important'>Never</span>" : "<span class='label label-success'>".$lastBounce . " minutes ago.</span>";
|
||||
|
||||
$text = "
|
||||
<form method='post' action='".e_SELF."?".e_QUERY."' id='mailsettingsform'>
|
||||
@ -1065,22 +1092,45 @@ class mailout_main_ui extends e_admin_ui
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>".LAN_MAILOUT_32."</td>
|
||||
<td>".$frm->text('mail_bounce_email2', $pref['mail_bounce_email'], 40, 'size=xxlarge')."</td>
|
||||
<td><div class='input-append'>".$frm->text('mail_bounce_email2', $pref['mail_bounce_email'], 40, 'size=xlarge');
|
||||
|
||||
if(!empty($pref['mail_bounce_email']))
|
||||
{
|
||||
$text .= $frm->admin_button('send_bounce_test','Send Test','primary','Test');
|
||||
}
|
||||
|
||||
$text .= "</div></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>".LAN_MAILOUT_233."</td><td><b>".(e_DOCROOT).e107::getFolder('handlers')."bounce_handler.php</b>";
|
||||
<td>".LAN_MAILOUT_233."</td><td><b>".(e_ROOT).e107::getFolder('handlers')."bounce_handler.php</b>";
|
||||
|
||||
$status = '';
|
||||
|
||||
|
||||
if(!is_readable(e_HANDLER.'bounce_handler.php'))
|
||||
{
|
||||
$text .= "<br /><span class='required'>".LAN_MAILOUT_161.'</span>';
|
||||
$status = LAN_MAILOUT_161;
|
||||
}
|
||||
elseif(!is_executable(e_HANDLER.'bounce_handler.php')) // Seems to give wrong answers on Windoze
|
||||
{
|
||||
$text .= "<br /><span class='required'>".LAN_MAILOUT_162.'</span>';
|
||||
$status = LAN_MAILOUT_162;
|
||||
}
|
||||
$text .= "<br /><span class='field-help'>".LAN_MAILOUT_235."</span></td></tr>
|
||||
else
|
||||
{
|
||||
// $text .= " ".ADMIN_TRUE_ICON;
|
||||
}
|
||||
|
||||
if(!empty($status))
|
||||
{
|
||||
$text .= " <span class='label label-warning'>".$status."</span>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$text .= "<div>".LAN_MAILOUT_235."</div>
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td>".LAN_MAILOUT_236."</td><td>".$lastBounceText."</td></tr>
|
||||
</tbody></table>";
|
||||
|
||||
|
@ -3,55 +3,79 @@
|
||||
|
||||
|
||||
// WARNING, any echoed output from this script will be returned to the sender as a bounce message.
|
||||
|
||||
$_E107['debug'] = false;
|
||||
|
||||
|
||||
|
||||
$_E107['debug'] = true;
|
||||
|
||||
if (!defined('e107_INIT'))
|
||||
{
|
||||
$_E107['cli'] = TRUE;
|
||||
$class2 = realpath(dirname(__FILE__)."/../")."/class2.php";
|
||||
require_once($class2);
|
||||
}
|
||||
$_E107['cli'] = true;
|
||||
$_E107['allow_guest'] = true; // allow to run while in members-only mode.
|
||||
$_E107['no_forceuserupdate'] = true;
|
||||
$_E107['no_maintenance'] = true;
|
||||
|
||||
if(ADMIN && varset($_GET['eml']))
|
||||
{
|
||||
$_E107['debug'] = true;
|
||||
$class2 = realpath(dirname(__FILE__)."/../")."/class2.php";
|
||||
|
||||
@require_once($class2);
|
||||
}
|
||||
|
||||
$bnc = new e107Bounce;
|
||||
$process = (varset($_GET['eml']) && $_E107['debug']) ? $_GET['eml'].".eml" : FALSE;
|
||||
$bnc->process($process);
|
||||
$bnc->process();
|
||||
|
||||
|
||||
|
||||
class e107Bounce
|
||||
{
|
||||
private $debug = false;
|
||||
private $source = false;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
if(ADMIN && vartrue($_GET['eml']))
|
||||
{
|
||||
$this->debug = true;
|
||||
$this->source = $_GET['eml'].".eml";
|
||||
}
|
||||
}
|
||||
|
||||
function process($source='')
|
||||
{
|
||||
global $_E107,$pref;
|
||||
|
||||
|
||||
$pref = e107::getPref();
|
||||
|
||||
e107::getCache()->CachePageMD5 = '_';
|
||||
e107::getCache()->set('emailLastBounce',time(),TRUE,FALSE,TRUE);
|
||||
|
||||
$strEmail= (!$source) ? $this->mailRead(-1) : file_get_contents(e_HANDLER."eml/".$source);
|
||||
$strEmail= ($this->source == false) ? $this->mailRead(-1) : file_get_contents(e_HANDLER."eml/".$this->source);
|
||||
|
||||
if(!$strEmail)
|
||||
if(strpos($strEmail,'X-Bounce-Test: true')!==false) // Bounce Test from Admin Area.
|
||||
{
|
||||
if($_E107['debug'] === true)
|
||||
$this->debug = true;
|
||||
}
|
||||
|
||||
if(empty($strEmail)) // Failed.
|
||||
{
|
||||
if($this->debug === true && !empty($this->source))
|
||||
{
|
||||
echo "Couldn't get email data";
|
||||
}
|
||||
return;
|
||||
else
|
||||
{
|
||||
$message = "Empty Email!";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$multiArray = Bouncehandler::get_the_facts($strEmail);
|
||||
$head = BounceHandler::parse_head($strEmail);
|
||||
$message = null;
|
||||
$identifier = deftrue('MAIL_IDENTIFIER', 'X-e107-id');
|
||||
$e107_userid = (isset($head[$identifier])) ? $head[$identifier] : $this->getHeader($strEmail, $identifier);
|
||||
}
|
||||
|
||||
$multiArray = Bouncehandler::get_the_facts($strEmail);
|
||||
$head = BounceHandler::parse_head($strEmail);
|
||||
$message = null;
|
||||
|
||||
|
||||
$identifier = deftrue('MAIL_IDENTIFIER', 'X-e107-id');
|
||||
$e107_userid = (isset($head[$identifier])) ? $head[$identifier] : $this->getHeader($strEmail, $identifier);
|
||||
|
||||
if($_E107['debug'])
|
||||
if($this->debug === true)
|
||||
{
|
||||
require_once(e_HANDLER."mail.php");
|
||||
$message = "Your Bounce Handler is working. The data of the email you sent is displayed below.<br />";
|
||||
@ -61,13 +85,13 @@ class e107Bounce
|
||||
$message .= "A user-id was detected in the email you sent: <b>".$e107_userid."</b><br />";
|
||||
}
|
||||
|
||||
$message .= "<br /><h4>Head</h4>";
|
||||
$message .= print_a($head,true);
|
||||
$message .= "<h4>Emails Found</h4><pre>".print_r($multiArray,TRUE). "</pre>";
|
||||
// $message .= "<br /><h4>Head</h4>";
|
||||
// $message .= print_a($head,true);
|
||||
// $message .= "<h4>Emails Found</h4><pre>".print_r($multiArray,TRUE). "</pre>";
|
||||
|
||||
$message .= "<pre>".$strEmail. "</pre>";
|
||||
|
||||
if(varset($_GET['eml']))
|
||||
if(!empty($this->source ))
|
||||
{
|
||||
echo $message;
|
||||
}
|
||||
@ -82,7 +106,7 @@ class e107Bounce
|
||||
{
|
||||
if($errors = $this->setUser_Bounced($e107_userid))
|
||||
{
|
||||
$mesage .= print_a($errors);
|
||||
// $message .= print_a($errors,true);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user