1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 12:48:24 +01:00

Standard mailer and bulk mailer can now be different. eg. Use PHP for standard mails, but use Amazon.com SES service for bulk mailing, mailing lists etc.

This commit is contained in:
Cameron 2016-04-14 14:48:02 -07:00
parent a0ee67407a
commit ca83bbf73e
7 changed files with 83 additions and 60 deletions

View File

@ -564,52 +564,57 @@ class mailout_main_ui extends e_admin_ui
if(trim($_POST['testaddress']) == '')
{
$mes->addError(LAN_MAILOUT_19);
$subAction = 'error';
return null;
}
if(empty($pref['bulkmailer']))
{
$pref['bulkmailer'] = $pref['mailer'];
}
$add = ($pref['bulkmailer']) ? " (".strtoupper($pref['bulkmailer']).") " : ' (PHP)';
if($pref['bulkmailer'] == 'smtp')
{
$add .= "Port: ".varset($pref['smtp_port'],25);
$add .= " - ".str_replace("secure=", "", $pref['smtp_options']);
}
$sendto = trim($_POST['testaddress']);
$subjectSitename = ($_POST['testtemplate'] == 'textonly') ? SITENAME : '';
$eml = array(
'e107_header' => USERID,
'subject' => LAN_MAILOUT_113." ".$subjectSitename.$add,
'body' => str_replace("[br]", "\n", LAN_MAILOUT_114),
'template' => vartrue($_POST['testtemplate'],null),
'shortcodes' => $this->getExampleShortcodes(),
'media' => array(
0 => array('path' => '{e_PLUGIN}gallery/images/butterfly.jpg'),
1 => array('path' => 'h-v880sXEOQ.youtube'),
)
);
if(E107_DEBUG_LEVEL > 0)
{
$eml['SMTPDebug'] = true;
}
$options = array('mailer'=>$pref['bulkmailer']);
if (!e107::getEmail($options)->sendEmail($sendto, LAN_MAILOUT_189, $eml))
{
$mes->addError(($pref['bulkmailer'] == 'smtp') ? LAN_MAILOUT_67 : LAN_MAILOUT_106);
}
else
{
$mes->addSuccess(LAN_MAILOUT_81. ' ('.$sendto.')');
e107::getAdminLog()->log_event('MAIL_01', $sendto, E_LOG_INFORMATIVE,'');
}
$add = ($pref['mailer']) ? " (".strtoupper($pref['mailer']).") " : ' (PHP)';
if($pref['mailer'] == 'smtp')
{
$add .= "Port: ".varset($pref['smtp_port'],25);
$add .= " - ".str_replace("secure=", "", $pref['smtp_options']);
}
$sendto = trim($_POST['testaddress']);
$subjectSitename = ($_POST['testtemplate'] == 'textonly') ? SITENAME : '';
$eml = array(
'e107_header' => USERID,
'subject' => LAN_MAILOUT_113." ".$subjectSitename.$add,
'body' => str_replace("[br]", "\n", LAN_MAILOUT_114),
'template' => vartrue($_POST['testtemplate'],null),
'shortcodes' => $this->getExampleShortcodes(),
'media' => array(
0 => array('path' => '{e_PLUGIN}gallery/images/butterfly.jpg'),
1 => array('path' => 'h-v880sXEOQ.youtube'),
)
);
if(E107_DEBUG_LEVEL > 0)
{
$eml['SMTPDebug'] = true;
}
if (!e107::getEmail()->sendEmail($sendto, LAN_MAILOUT_189, $eml))
{
$mes->addError(($pref['mailer'] == 'smtp') ? LAN_MAILOUT_67 : LAN_MAILOUT_106);
}
else
{
$mes->addSuccess(LAN_MAILOUT_81. ' ('.$sendto.')');
e107::getAdminLog()->log_event('MAIL_01', $sendto, E_LOG_INFORMATIVE,'');
}
}
}
@ -1087,7 +1092,7 @@ class mailout_main_ui extends e_admin_ui
<td>";
$text .= mailoutAdminClass::mailerPrefsTable($pref);
$text .= mailoutAdminClass::mailerPrefsTable($pref, 'bulkmailer');
/* FIXME - posting SENDMAIL path triggers Mod-Security rules.

View File

@ -168,6 +168,7 @@
<core name="mail_sendstyle">texthtml</core>
<core name="mail_workpertick">5</core>
<core name="mailer">php</core>
<core name="bulkmailer">smtp</core>
<core name="main_wordwrap"></core>
<core name="maintainance_flag">0</core>
<core name="make_clickable">0</core>

View File

@ -775,11 +775,17 @@ class e107
* @param string $regpath additional registry path
* @return Object
*/
public static function getSingleton($class_name, $path = true, $regpath = '')
public static function getSingleton($class_name, $path = true, $regpath = '',$vars=null)
{
$id = 'core/e107/singleton/'.$class_name.$regpath;
if(!empty($vars))
{
$id .= '/';
$id .= is_array($vars) ? crc32(serialize($vars)): crc32($vars);
}
//singleton object found - overload not possible
if(self::getRegistry($id))
{
@ -821,7 +827,7 @@ class e107
}
if(class_exists($class_name, false))
{
e107::setRegistry($id, new $class_name());
e107::setRegistry($id, new $class_name($vars));
}
return self::getRegistry($id);
@ -1225,9 +1231,9 @@ class e107
*
* @return e107Email
*/
public static function getEmail()
public static function getEmail($overrides=null)
{
return self::getSingleton('e107Email', true);
return self::getSingleton('e107Email', true, null, $overrides);
}

View File

@ -196,6 +196,8 @@ class e107Email extends PHPMailer
$e107 = e107::getInstance();
$pref = e107::pref('core');
$tp = e107::getParser();
print_a($overrides);
if(defined('MAIL_DEBUG'))
{

View File

@ -216,9 +216,19 @@ class e107MailManager
*
* @return void
*/
public function __construct($overrides = FALSE)
public function __construct($overrides = false)
{
$this->e107 = e107::getInstance();
$pref = e107::pref('core');
$bulkmailer = (!empty($pref['bulkmailer'])) ? $pref['bulkmailer'] : $pref['mailer'];
if($overrides === false)
{
$overrides = array('mailer'=>$bulkmailer);
}
$this->mailOverrides = $overrides;
if(deftrue('e_DEBUG'))
@ -247,7 +257,7 @@ class e107MailManager
*
* @return void
*/
public function mailToDb(&$data, $addMissing = FALSE)
public function mailToDb(&$data, $addMissing = false)
{
$res = array();
$res1 = array();
@ -745,10 +755,9 @@ class e107MailManager
}
// else
{
$result = $this->mailer->sendEmail($email['mail_recipient_email'], $email['mail_recipient_name'], $mailToSend, TRUE);
}
$result = $this->mailer->sendEmail($email['mail_recipient_email'], $email['mail_recipient_name'], $mailToSend, TRUE);
if($this->debugMode)
{
@ -1310,7 +1319,7 @@ class e107MailManager
if (!$this->db->update('mail_content',$query))
{
$this->e107->admin_log->e_log_event(10,-1,'MAIL','Activate/hold mail','mail_content: '.$query.'[!br!]Fail: '.$this->db->mySQLlastErrText,FALSE,LOG_TO_ROLLING);
e107::getLog()->e_log_event(10,-1,'MAIL','Activate/hold mail','mail_content: '.$query.'[!br!]Fail: '.$this->db->mySQLlastErrText,FALSE,LOG_TO_ROLLING);
return FALSE;
}
@ -1319,7 +1328,7 @@ class e107MailManager
// echo "Update individual emails: {$query}<br />";
if (FALSE === $this->db->update('mail_recipients',$query))
{
$this->e107->admin_log->e_log_event(10,-1,'MAIL','Activate/hold mail','mail_recipient: '.$query.'[!br!]Fail: '.$this->db->mySQLlastErrText,FALSE,LOG_TO_ROLLING);
e107::getLog()->e_log_event(10,-1,'MAIL','Activate/hold mail','mail_recipient: '.$query.'[!br!]Fail: '.$this->db->mySQLlastErrText,FALSE,LOG_TO_ROLLING);
return FALSE;
}
return TRUE;

View File

@ -2102,7 +2102,7 @@ class mailoutAdminClass extends e107MailManager
public static function mailerPrefsTable($pref)
public static function mailerPrefsTable($pref, $id='mailer')
{
$frm = e107::getForm();
@ -2110,9 +2110,9 @@ class mailoutAdminClass extends e107MailManager
$mailers = array('php'=>'php','smtp'=>'smtp','sendmail'=>'sendmail');
$smtp_opts = explode(',',varset($pref['smtp_options'],''));
$smtpdisp = ($pref['mailer'] != 'smtp') ? "style='display:none;'" : '';
$smtpdisp = ($pref[$id] != 'smtp') ? "style='display:none;'" : '';
$text = $frm->select('mailer', $mailers, $pref['mailer'])."
$text = $frm->select($id, $mailers, $pref[$id])."
<span class='field-help'>".LAN_MAILOUT_116."</span>";
$text .= "<div id='smtp' {$smtpdisp}>
@ -2193,7 +2193,7 @@ class mailoutAdminClass extends e107MailManager
e107::js('footer-inline', "
$('#mailer').on('change', function() {
$('#".$id."').on('change', function() {
var type = $(this).val();

View File

@ -125,7 +125,7 @@ define("LAN_MAILOUT_111", "Email Title (not sent)");
define("LAN_MAILOUT_112", "Send test email to");
define("LAN_MAILOUT_113", "Test email from");
define("LAN_MAILOUT_114", "This is a test email, it appears that your email settings are working ok! [br][br] Regards [br] from the e107 website system.");
define("LAN_MAILOUT_115", "Emailing method");
define("LAN_MAILOUT_115", "Bulk Emailing method");
define("LAN_MAILOUT_116", "If unsure, leave as php");
define("LAN_MAILOUT_117", "complete");
define("LAN_MAILOUT_118", "Click on proceed' to start sending emails. Click on 'cancel' to stop the run. Once complete, select another page. Unsent emails cal be viewed through the 'Mailshot status' screen");