1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-19 20:21:51 +02:00

Fix for notifications to less than 5 people. Notification now come from the site email, not the admin email.

This commit is contained in:
Cameron 2015-05-13 17:45:24 -07:00
parent d596abc90a
commit c73c07490b
4 changed files with 75 additions and 19 deletions

View File

@ -819,7 +819,6 @@ class e107Email extends PHPMailer
}
$identifier = deftrue('MAIL_IDENTIFIER', 'X-e107-id');
if (isset($eml['SMTPDebug'])) { $this->SMTPDebug = $eml['SMTPDebug']; } // 'FALSE' is a valid value!
@ -959,6 +958,7 @@ class e107Email extends PHPMailer
$_SERVER["HTTP_CF_CONNECTING_IP"] = $_SERVER['SERVER_ADDR'];
$result = $this->Send(); // Actually send email
$_SERVER['PHP_SELF'] = $oldphpself;
$_SERVER['REMOTE_ADDR'] = $oldremoteaddr;

View File

@ -840,18 +840,41 @@ class e107MailManager
/**
* Given an email block, creates an array of data compatible with PHPMailer, including any necessary substitutions
* $eml['subject']
$eml['sender_email'] - 'From' email address
$eml['sender_name'] - 'From' name
$eml['replyto'] - Optional 'reply to' field
$eml['replytonames'] - Name(s) corresponding to 'reply to' field - only used if 'replyto' used
$eml['send_html'] - if TRUE, includes HTML part in messages (only those added after this flag)
$eml['add_html_header'] - if TRUE, adds the 2-line DOCTYPE declaration to the front of the HTML part (but doesn't add <head>...</head>)
$eml['body'] - message body. May be HTML or text. Added according to the current state of the HTML enable flag
$eml['attach'] - string if one file, array of filenames if one or more.
$eml['copy_to'] - comma-separated list of cc addresses.
$eml['cc_names'] - comma-separated list of cc names. Optional, used only if $eml['copy_to'] specified
$eml['bcopy_to'] - comma-separated list
$eml['bcc_names'] - comma-separated list of bcc names. Optional, used only if $eml['copy_to'] specified
$eml['bouncepath'] - Sender field (used for bounces)
$eml['returnreceipt'] - email address for notification of receipt (reading)
$eml['inline_images'] - array of files for inline images
$eml['priority'] - Email priority (1 = High, 3 = Normal, 5 = low)
$eml['e107_header'] - Adds specific 'X-e107-id:' header
$eml['extra_header'] - additional headers (format is name: value
$eml['wordwrap'] - Set wordwrap value
$eml['split'] - If true, sends an individual email to each recipient
$eml['template'] - template to use. 'default'
$eml['shortcodes'] - array of shortcode values. eg. array('MY_SHORTCODE'=>'12345');
*/
protected function makeEmailBlock($email)
{
$mailSubsInfo = array(
'email_subject' => 'mail_subject',
'email_sender_email' => 'mail_sender_email',
'email_sender_name' => 'mail_sender_name',
'subject' => 'mail_subject',
'sender_email' => 'mail_sender_email',
'sender_name' => 'mail_sender_name',
// 'email_replyto' - Optional 'reply to' field
// 'email_replytonames' - Name(s) corresponding to 'reply to' field - only used if 'replyto' used
'email_copy_to' => 'mail_copy_to', // - comma-separated list of cc addresses.
'copy_to' => 'mail_copy_to', // - comma-separated list of cc addresses.
//'email_cc_names' - comma-separated list of cc names. Optional, used only if $eml['email_copy_to'] specified
'email_bcopy_to' => 'mail_bcopy_to',
'bcopy_to' => 'mail_bcopy_to',
// 'email_bcc_names' - comma-separated list of bcc names. Optional, used only if $eml['email_copy_to'] specified
//'bouncepath' - Sender field (used for bounces)
//'returnreceipt' - email address for notification of receipt (reading)
@ -863,18 +886,30 @@ class e107MailManager
'template' => 'mail_send_style', // required
'shortcodes' => 'mail_target_info' // required
);
$result = array();
if (!isset($email['mail_source_id'])) $email['mail_source_id'] = 0;
if (!isset($email['mail_target_id'])) $email['mail_target_id'] = 0;
if (!isset($email['mail_recipient_id'])) $email['mail_recipient_id'] = 0;
foreach ($mailSubsInfo as $k => $v)
{
if (isset($email[$v]))
{
$result[$k] = $email[$v];
//unset($email[$v]);
}
}
// Do any substitutions
$search = array();
$replace = array();
@ -883,14 +918,17 @@ class e107MailManager
$search[] = '|'.$k.'|';
$replace[] = $v;
}
$result['email_body'] = str_replace($search, $replace, $this->currentMailBody);
if ($this->currentTextBody)
{
$result['mail_body_alt'] = str_replace($search, $replace, $this->currentTextBody);
}
$result['send_html'] = ($email['mail_send_style'] != 'textonly');
$result['add_html_header'] = FALSE; // We look after our own headers
// Set up any extra mailer parameters that need it
@ -1775,19 +1813,25 @@ class e107MailManager
$eCount = 0;
// @TODO: Generate alt text etc
foreach ($recipientData as $recip)
{
// Fill in other bits of email
$emailData['mail_target_info'] = $recip;
$mailToSend = $this->makeEmailBlock($emailData); // Substitute mail-specific variables, attachments etc
if (FALSE == $this->mailer->sendEmail($recip['mail_recipient_email'], $recip['mail_recipient_name'], $mailToSend, TRUE))
// $emailData['mail_target_info'] = $recip ;
$merged = array_merge($emailData,$recip);
$mailToSend = $this->makeEmailBlock($merged); // Substitute mail-specific variables, attachments etc
/*
echo "<h2>MERGED</h2>";
print_a($merged);
echo "<h2>RETURNED</h2>";
print_a($mailToSend);
echo "<hr />";
continue;
*/
if (FALSE == $this->mailer->sendEmail($recip['mail_recipient_email'], $recip['mail_recipient_name'], $mailToSend, true))
{
$tempResult = FALSE;
if($this->debugMode)
@ -1814,7 +1858,10 @@ class e107MailManager
return $tempResult;
}
// To many recipients to send at once - add to the emailing queue
// ----------- Too many recipients to send at once - add to the emailing queue ---------------- //
// @TODO - handle any other relevant $extra fields
$emailData['mail_total_count'] = count($recipientData);

View File

@ -219,12 +219,15 @@ class notify
if(E107_DEBUG_LEVEL > 0)
{
$data = array('id'=>$id, 'subject'=>$subject, 'recipients'=> $recipients, 'prefs'=>$this->notify_prefs['event'][$id], 'message'=>$message);
e107::getMessage()->addDebug("<b>Mailing is simulated only while in DEBUG mode.</b>");
e107::getMessage()->addDebug(print_a($data,true));
e107::getLog()->add('Notify Debug', $data, E_LOG_INFORMATIVE, "NOTIFY_DBG");
return;
}
$siteadminemail = e107::getPref('siteadminemail');
$siteadmin = e107::getPref('siteadmin');
if (count($recipients))
{
@ -238,8 +241,8 @@ class notify
'mail_create_app' => 'notify',
'mail_title' => 'NOTIFY',
'mail_subject' => $subject,
'mail_sender_email' => e107::getPref('siteadminemail'),
'mail_sender_name' => e107::getPref('siteadmin'),
'mail_sender_email' => e107::getPref('replyto_email',$siteadminemail),
'mail_sender_name' => e107::getPref('replyto_name',$siteadmin),
'mail_notify_complete' => 0, // NEVER notify when this email sent!!!!!
'mail_body' => $message,
'template' => 'notify',

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<e107Plugin name="User" version="1.0" date="2014-01-01" compatibility="2.0" installRequired="false" >
<author name="e107 Inc." url="http://e107.org" />
<description>User Theme and Language Menus</description>
<category>user</category>
</e107Plugin>