mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
Issue #70 - update PHPMailer to latest.
New mail entry point to send templated emails, bulk emails etc Add option to mass-send templated emails from admin page 'Notify' function uses the new interface. Sundry detail improvements Other sources of auto-generated emails need converting - signup etc Much more testing needed. Needs competent themer to generate some nice templates.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2010 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
@@ -399,6 +399,7 @@ switch ($action)
|
||||
case 'sent' :
|
||||
case 'pending' :
|
||||
case 'held' :
|
||||
case 'mailshowtemplate' :
|
||||
if (isset($_POST['etrigger_ecolumns']))
|
||||
{
|
||||
$mailAdmin->mailbodySaveColumnPref($action);
|
||||
@@ -554,6 +555,10 @@ switch ($action)
|
||||
$mailAdmin->showEmailList($action, -1, -1);
|
||||
break;
|
||||
|
||||
case 'mailshowtemplate' : // Show the templated email
|
||||
$mailAdmin->showEmailTemplate($mailId);
|
||||
break;
|
||||
|
||||
case 'maildelete' : // NOTE:: need to set previous page in form
|
||||
$mailAdmin->showDeleteConfirm($mailId, $pageMode);
|
||||
break;
|
||||
@@ -679,7 +684,14 @@ function saveMailPrefs(&$emessage)
|
||||
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
|
||||
if ((strpos($_POST['sendmail'],'sendmail') !== FALSE) || (strpos($_POST['sendmail'],'qmail') !== FALSE)) $temp['sendmail'] = $e107->tp->toDB($_POST['sendmail']);
|
||||
if ((strpos($_POST['sendmail'],'sendmail') !== FALSE) || (strpos($_POST['sendmail'],'qmail') !== FALSE))
|
||||
{
|
||||
$temp['sendmail'] = $e107->tp->toDB($_POST['sendmail']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$temp['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']);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
|
@@ -2,28 +2,37 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2010 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* e107 Main
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_handlers/redirection_class.php $
|
||||
* $Id: redirection_class.php 11922 2010-10-27 11:31:18Z secretr $
|
||||
* $Revision: 11315 $
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package e107
|
||||
* @subpackage e107_handlers
|
||||
* @version $Revision$
|
||||
* @author $Author$
|
||||
|
||||
* @version $Revision: 12078 $
|
||||
* @author $Author: e107coders $
|
||||
*
|
||||
* Mailout handler - concerned with processing and sending a single email
|
||||
*/
|
||||
* Extends the PHPMailer class
|
||||
*/
|
||||
|
||||
/*
|
||||
TODO:
|
||||
1. Mustn't include header in text section of emails
|
||||
2. Option to wrap HTML in a standard header (up to <body>) and footer (from </body>)
|
||||
|
||||
Maybe each template is an array with several parts - optional header and footer, use defaults if not defined
|
||||
header looks for the {STYLESHEET} variable
|
||||
If we do that, can have a single override file, plus a core file
|
||||
|
||||
3. mail (PHP method) - note that it has parameters for additional headers and other parameters
|
||||
4. Check that language support works - PHPMailer defaults to English if other files not available
|
||||
- PHPMailer expects a 2-letter code - $this->SetLanguage(CORE_LC) - e.g. 'en', 'br'
|
||||
@@ -32,12 +41,11 @@ TODO:
|
||||
- Look at support of some other logging options
|
||||
9. Make sure SMTPDebug can be set (TRUE/FALSE)
|
||||
12. Check support for port number - ATM we just override for SSL. Looks as if phpmailer can take it from end of server link.
|
||||
13. Possibly strip bbcode from plain text mailings - best done by caller?
|
||||
18. Note object iteration - may be useful for dump of object state
|
||||
19. Consider overriding error handler
|
||||
20. Look at using new prefs structure
|
||||
21. Should we always send an ID?
|
||||
22. Force singleton so all mail sending flow controlled a bit
|
||||
22. Force singleton so all mail sending flow controlled a bit (but not where parameters overridden in constructor)
|
||||
|
||||
|
||||
Tested so far (with PHP4 version)
|
||||
@@ -150,14 +158,14 @@ class e107Email extends PHPMailer
|
||||
private $TotalErrors = 0; // Count errors in sending emails
|
||||
private $pause_amount = 10; // Number of emails to send before pausing/resetting (or closing if SMTPkeepAlive set)
|
||||
private $pause_time = 1; // Time to pause after sending a block of emails
|
||||
private $templateOption = array();
|
||||
public $legacyBody = FALSE; // TRUE enables legacy conversion of plain text body to HTML in HTML emails
|
||||
public $template = "email"; // Choice of email, notify or mailout
|
||||
|
||||
/**
|
||||
public $legacyBody = FALSE; // TRUE enables legacy conversion of plain text body to HTML in HTML emails
|
||||
|
||||
/**
|
||||
* Constructor sets up all the global options, and sensible defaults - it should be the only place the prefs are accessed
|
||||
*
|
||||
* @var array $overrides - array of values which override mail-related prefs. Key is the same as the corresponding pref.
|
||||
* - second batch of keys can preset values configurable through the arraySet() method
|
||||
* @return none
|
||||
*/
|
||||
public function __construct($overrides = FALSE)
|
||||
@@ -165,13 +173,7 @@ class e107Email extends PHPMailer
|
||||
parent::__construct(FALSE); // Parent constructor - no exceptions for now
|
||||
|
||||
$e107 = e107::getInstance();
|
||||
global $pref;
|
||||
|
||||
//Load up Email Templates
|
||||
include(e107::coreTemplatePath('email','front'));
|
||||
$this->templateOption['email'] = array('header'=>$EMAIL_HEADER,'footer'=>$EMAIL_FOOTER);
|
||||
$this->templateOption['notify'] = array('header'=>$NOTIFY_HEADER,'footer'=>$NOTIFY_FOOTER);
|
||||
$this->templateOption['mailout'] = array('header'=>$MAILOUT_HEADER,'footer'=>$MAILOUT_FOOTER);
|
||||
$pref = e107::pref('core');
|
||||
|
||||
$this->CharSet = 'utf-8';
|
||||
$this->SetLanguage(CORE_LC);
|
||||
@@ -181,7 +183,7 @@ class e107Email extends PHPMailer
|
||||
$overrides = array();
|
||||
}
|
||||
|
||||
foreach (array('mailer', 'smtp_server', 'smtp_username', 'smtp_password', 'sendmail', 'siteadminemail', 'siteadmin', 'smtp_pop3auth') as $k)
|
||||
foreach (array('mailer', 'smtp_server', 'smtp_username', 'smtp_password', 'sendmail', 'siteadminemail', 'siteadmin') as $k)
|
||||
{
|
||||
if (!isset($overrides[$k])) $overrides[$k] = $pref[$k];
|
||||
}
|
||||
@@ -277,8 +279,9 @@ class e107Email extends PHPMailer
|
||||
|
||||
// Now look for any overrides - slightly cumbersome way of doing it, but does give control over what can be set from here
|
||||
// Options are those accepted by the arraySet() method.
|
||||
foreach (array('SMTPDebug', 'subject', 'from', 'fromname', 'replyto', 'send_html', 'add_html_header', 'attachments', 'cc', 'bcc',
|
||||
'bouncepath', 'returnreceipt', 'priority', 'extra_header', 'wordwrap', 'split') as $opt)
|
||||
foreach (array('SMTPDebug', 'email_subject', 'email_sender_email', 'email_sender_name', 'email_replyto', 'send_html',
|
||||
'add_html_header', 'email_attach', 'email_copy_to', 'email_bcopy_to',
|
||||
'bouncepath', 'returnreceipt', 'email_inline_images', 'email_priority', 'extra_header', 'wordwrap', 'split') as $opt)
|
||||
{
|
||||
if (isset($overrides[$opt]))
|
||||
{
|
||||
@@ -348,7 +351,7 @@ class e107Email extends PHPMailer
|
||||
fwrite($this->logHandle,"\n\n=====".date('H:i:s y.m.d')."----------------------------------------------------------------=====\r\n");
|
||||
if ($logInfo)
|
||||
{
|
||||
fwrite($this->logHandle,' Mailer opened by '.USERNAME." - ID: {$mail_id}. Subject: {$this->Subject} Log action: {$this->logEnable}\r\n");
|
||||
fwrite($this->logHandle,' Mailer opened by '.USERNAME." - ID: {$this->MessageID}. Subject: {$this->Subject} Log action: {$this->logEnable}\r\n");
|
||||
if ($this->add_email)
|
||||
{
|
||||
fwrite($this->logHandle, 'From: '.$this->From.' ('.$this->FromName.")\r\n");
|
||||
@@ -377,6 +380,12 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a line to log file - time/date is prepended, and CRLF is appended
|
||||
*
|
||||
* @param string $text - line to add
|
||||
* @return none
|
||||
*/
|
||||
protected function logLine($text)
|
||||
{
|
||||
if ($this->logEnable && ($this->logHandle > 0))
|
||||
@@ -385,6 +394,9 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close log
|
||||
*/
|
||||
protected function closeLog()
|
||||
{
|
||||
if ($this->logEnable && ($this->logHandle > 0))
|
||||
@@ -456,10 +468,14 @@ class e107Email extends PHPMailer
|
||||
|
||||
|
||||
|
||||
|
||||
// New method of making a body uses the inbuilt functionality of phpmailer
|
||||
// $want_HTML= 1 uses default setting for HTML part. Set TRUE to enable, FALSE to disable
|
||||
// $add_HTML_header - if TRUE, a standard HTML header is added to the front of the HTML part
|
||||
/**
|
||||
* Create email body, primarily using the inbuilt functionality of phpmailer
|
||||
*
|
||||
* @param boolean|int $want_HTML determines whether an HTML part of the email is created. 1 uses default setting for HTML part. Set TRUE to enable, FALSE to disable
|
||||
* @param boolean $add_HTML_header - if TRUE, a standard HTML header is added to the front of the HTML part
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function makeBody($message,$want_HTML = 1, $add_HTML_header = FALSE)
|
||||
{
|
||||
switch (varset($this->general_opts['textonly'],'off'))
|
||||
@@ -516,8 +532,14 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Add attachments - either a single one as a string, or an array
|
||||
/**
|
||||
* Add attachments to the current email - either a single one as a string, or an array
|
||||
* Always sent in base64 encoding
|
||||
*
|
||||
* @param string|array $attachments - single attachment name as a string, or any number as an array
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function attach($attachments)
|
||||
{
|
||||
if (!$attachments) return;
|
||||
@@ -535,11 +557,15 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
|
||||
|
||||
// Add inline images (should mostly be handled automatically)
|
||||
/**
|
||||
* Add inline images (should usually be handled automatically by PHPMailer)
|
||||
*
|
||||
* @param string $inline - comma separated list of file names
|
||||
*/
|
||||
function addInlineImages($inline)
|
||||
{
|
||||
if(!$inline) return;
|
||||
$tmp = explode(",",$inline);
|
||||
$tmp = explode(',',$inline);
|
||||
foreach($tmp as $inline_img)
|
||||
{
|
||||
if(is_readable($inline_img) && !is_dir($inline_img))
|
||||
@@ -551,31 +577,36 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
|
||||
|
||||
// Sets one or more parameters from an array. See send_array() for list of parameters
|
||||
// Where parameter not present, doesn't change it - so can repeatedly call this function for bulk mailing, or to build up the list
|
||||
// Return 0 on success.
|
||||
// (Note that there is no requirement to use this method for everything; parameters can be set by mixing this method with individual setting)
|
||||
/**
|
||||
* Sets one or more parameters from an array. See @see{sendEmail()} for list of parameters
|
||||
* Where parameter not present, doesn't change it - so can repeatedly call this function for bulk mailing, or to build up the list
|
||||
* (Note that there is no requirement to use this method for everything; parameters can be set by mixing this method with individual setting)
|
||||
*
|
||||
* @param array $paramlist - list of parameters to set/change. Key is parameter name. @see{sendEmail()} for list of parameters
|
||||
*
|
||||
* @return int zero if no errors detected
|
||||
*/
|
||||
public function arraySet($paramlist)
|
||||
{
|
||||
if (isset($paramlist['SMTPDebug'])) $this->SMTPDebug = $paramlist['SMTPDebug']; // 'FALSE' is a valid value!
|
||||
if (varsettrue($paramlist['mail_subject'])) $this->Subject = $paramlist['mail_subject'];
|
||||
if (varsettrue($paramlist['mail_sender_email'])) $this->From = $paramlist['mail_sender_email'];
|
||||
if (varsettrue($paramlist['mail_sender_name'])) $this->FromName = $paramlist['mail_sender_name'];
|
||||
if (varsettrue($paramlist['mail_replyto'])) $this->AddAddressList('replyto',$paramlist['mail_replyto'],varsettrue($paramlist['mail_replytonames'],''));
|
||||
if (varsettrue($paramlist['email_subject'])) $this->Subject = $paramlist['email_subject'];
|
||||
if (varsettrue($paramlist['email_sender_email'])) $this->From = $paramlist['email_sender_email'];
|
||||
if (varsettrue($paramlist['email_sender_name'])) $this->FromName = $paramlist['email_sender_name'];
|
||||
if (varsettrue($paramlist['email_replyto'])) $this->AddAddressList('replyto',$paramlist['email_replyto'],varsettrue($paramlist['email_replytonames'],''));
|
||||
if (isset($paramlist['send_html'])) $this->allow_html = $paramlist['send_html']; // 'FALSE' is a valid value!
|
||||
if (isset($paramlist['add_html_header'])) $this->add_HTML_header = $paramlist['add_html_header']; // 'FALSE' is a valid value!
|
||||
if (varsettrue($paramlist['mail_body'])) $this->makeBody($paramlist['mail_body'], $this->allow_html, $this->add_HTML_header);
|
||||
if (varsettrue($paramlist['mail_attach'])) $this->attach($paramlist['mail_attach']);
|
||||
if (varsettrue($paramlist['mail_copy_to'])) $this->AddAddressList('cc',$paramlist['mail_copy_to'],varsettrue($paramlist['mail_cc_names'],''));
|
||||
if (varsettrue($paramlist['mail_bcopy_to'])) $this->AddAddressList('bcc',$paramlist['mail_bcopy_to'],varsettrue($paramlist['mail_bcc_names'],''));
|
||||
if (varsettrue($paramlist['email_body'])) $this->makeBody($paramlist['email_body'], $this->allow_html, $this->add_HTML_header);
|
||||
if (varsettrue($paramlist['email_attach'])) $this->attach($paramlist['email_attach']);
|
||||
if (varsettrue($paramlist['email_copy_to'])) $this->AddAddressList('cc',$paramlist['email_copy_to'],varsettrue($paramlist['email_cc_names'],''));
|
||||
if (varsettrue($paramlist['email_bcopy_to'])) $this->AddAddressList('bcc',$paramlist['email_bcopy_to'],varsettrue($paramlist['email_bcc_names'],''));
|
||||
if (varsettrue($paramlist['bouncepath']))
|
||||
{
|
||||
$this->Sender = $paramlist['bouncepath']; // Bounce path
|
||||
$this->save_bouncepath = $paramlist['bouncepath']; // Bounce path
|
||||
}
|
||||
if (varsettrue($paramlist['returnreceipt'])) $this->ConfirmReadingTo = $paramlist['returnreceipt'];
|
||||
if (varsettrue($paramlist['mail_inline_images'])) $this->addInlineImages($paramlist['mail_inline_images']);
|
||||
if (varsettrue($paramlist['mail_priority'])) $this->Priority = $paramlist['mail_priority'];
|
||||
if (varsettrue($paramlist['email_inline_images'])) $this->addInlineImages($paramlist['email_inline_images']);
|
||||
if (varsettrue($paramlist['email_priority'])) $this->Priority = $paramlist['email_priority'];
|
||||
if (varsettrue($paramlist['e107_header'])) $this->AddCustomHeader("X-e107-id: {$paramlist['e107_header']}");
|
||||
if (varsettrue($paramlist['extra_header']))
|
||||
{
|
||||
@@ -599,38 +630,45 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
Send an email where the bulk of the data is passed in an array. Returns 0 on success.
|
||||
(Even if the array is null, because everything previously set up, this is the preferred entry point)
|
||||
Where parameter not present in the array, doesn't get changed - useful for bulk mailing
|
||||
If doing bulk mailing with repetitive calls, set $bulkmail parameter true, and must call allSent() when completed
|
||||
Some of these parameters have been made compatible with the array calculated by render_email() in signup.php
|
||||
Possible array parameters:
|
||||
$eml['mail_subject']
|
||||
$eml['mail_sender_email'] - 'From' email address
|
||||
$eml['mail_sender_name'] - 'From' name
|
||||
$eml['mail_replyto'] - Optional 'reply to' field
|
||||
$eml['mail_replytonames'] - Name(s) corresponding to 'reply to' field - only used if 'replyto' used
|
||||
$eml['email_subject']
|
||||
$eml['email_sender_email'] - 'From' email address
|
||||
$eml['email_sender_name'] - 'From' name
|
||||
$eml['email_replyto'] - Optional 'reply to' field
|
||||
$eml['email_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['mail_body'] - message body. May be HTML or text. Added according to the current state of the HTML enable flag
|
||||
$eml['mail_attach'] - string if one file, array of filenames if one or more.
|
||||
$eml['mail_copy_to'] - comma-separated list of cc addresses.
|
||||
$eml['mail_cc_names''] - comma-separated list of cc names. Optional, used only if $eml['mail_copy_to'] specified
|
||||
$eml['mail_bcopy_to'] - comma-separated list
|
||||
$eml['mail_bcc_names''] - comma-separated list of bcc names. Optional, used only if $eml['mail_copy_to'] specified
|
||||
$eml['email_body'] - message body. May be HTML or text. Added according to the current state of the HTML enable flag
|
||||
$eml['email_attach'] - string if one file, array of filenames if one or more.
|
||||
$eml['email_copy_to'] - comma-separated list of cc addresses.
|
||||
$eml['email_cc_names'] - comma-separated list of cc names. Optional, used only if $eml['email_copy_to'] specified
|
||||
$eml['email_bcopy_to'] - comma-separated list
|
||||
$eml['email_bcc_names'] - comma-separated list of bcc names. Optional, used only if $eml['email_copy_to'] specified
|
||||
$eml['bouncepath'] - Sender field (used for bounces)
|
||||
$eml['returnreceipt'] - email address for notification of receipt (reading)
|
||||
$eml['mail_inline_images'] - array of files for inline images
|
||||
$eml['email_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
|
||||
|
||||
* @param string $send_to - recipient email address
|
||||
* @param string $to_name - recipient name
|
||||
* @param array $eml - optional array of additional parameters (see above)
|
||||
* @param boolean $bulkmail - set TRUE if this email is one of a bulk send; FALSE if an isolated email
|
||||
*
|
||||
* @return boolean|string - TRUE if success, error message if failure
|
||||
*/
|
||||
public function sendEmail($send_to, $to_name, $eml = '', $bulkmail = FALSE)
|
||||
{
|
||||
// $e107 = e107::getInstance();
|
||||
if (count($eml))
|
||||
{ // Set parameters from list
|
||||
$ret = $this->arraySet($eml);
|
||||
@@ -663,7 +701,8 @@ class e107Email extends PHPMailer
|
||||
else
|
||||
{ // Debug
|
||||
$result = TRUE;
|
||||
if (($logenable == 3) && (($this->SendCount % 7) == 4)) $result = FALSE; // Fail one email in 7 for testing
|
||||
//print_a($this);
|
||||
if (($this->logEnable == 3) && (($this->SendCount % 7) == 4)) $result = FALSE; // Fail one email in 7 for testing
|
||||
}
|
||||
|
||||
$this->TotalSent++;
|
||||
@@ -674,7 +713,7 @@ class e107Email extends PHPMailer
|
||||
$this->SendCount = 0;
|
||||
}
|
||||
|
||||
$this->logLine("Send to {$to_name} at {$send_to} Mail-ID={$mail_custom} - ".($result ? 'Success' : 'Fail'));
|
||||
$this->logLine("Send to {$to_name} at {$send_to} Mail-ID={$this->MessageID} - ".($result ? 'Success' : 'Fail'));
|
||||
|
||||
$this->ClearAddresses(); // In case we send another email
|
||||
$this->ClearCustomHeaders();
|
||||
@@ -695,7 +734,12 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
|
||||
|
||||
// Called after a bulk mailing completed, to tidy up nicely
|
||||
|
||||
/**
|
||||
* Called after a bulk mailing completed, to tidy up nicely
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function allSent()
|
||||
{
|
||||
if ($this->SMTPKeepAlive && ($this->Mailer == 'smtp') && ($this->SendCount > 0))
|
||||
@@ -705,25 +749,21 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Evaluates the message and returns modifications for inline images and backgrounds
|
||||
* Also creates an alternative plain text part (unless $this->AltBody already non-empty)
|
||||
* Modification of standard PHPMailer function (which it overrides)
|
||||
* @access public
|
||||
* @return $message
|
||||
*
|
||||
* @param string $message - the mail body to send
|
||||
* @basedir string - optional 'root part' of paths specified in email - prepended as necessary
|
||||
*
|
||||
* @return string none (message saved ready to send)
|
||||
*/
|
||||
public function MsgHTML($message, $basedir = '')
|
||||
{
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
$EMAIL_HEADER = $tp->parseTemplate($this->templateOption[$this->template]['header']);
|
||||
$EMAIL_FOOTER = $tp->parseTemplate($this->templateOption[$this->template]['footer']);
|
||||
|
||||
$message = $EMAIL_HEADER.$message.$EMAIL_FOOTER;
|
||||
|
||||
|
||||
|
||||
preg_match_all("/(src|background)=([\"\'])(.*)\\2/Ui", $message, $images); // Modified to accept single quotes as well
|
||||
if(isset($images[3]))
|
||||
{
|
||||
@@ -760,13 +800,12 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->IsHTML(true);
|
||||
$this->Body = $message;
|
||||
|
||||
// print_a($message);
|
||||
//print_a($message);
|
||||
$textMsg = str_replace(array('<br />', '<br>'), "\n", $message); // Modified to make sure newlines carried through
|
||||
$textMsg = preg_replace('#^.*?<body.*?>#', '', $textMsg); // Knock off everything up to and including the body statement (if present)
|
||||
$textMsg = preg_replace('#</body.*?>.*$#', '', $textMsg); // Knock off everything after and including the </body> (if present)
|
||||
$textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$textMsg)));
|
||||
if (!empty($textMsg) && empty($this->AltBody))
|
||||
{
|
||||
@@ -778,7 +817,6 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // End of e107Mailer class
|
||||
|
||||
|
||||
@@ -820,19 +858,42 @@ class e107Exception extends Exception
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Legacy interface for backward compatibility
|
||||
// Function call to send an email
|
||||
//-----------------------------------------------------
|
||||
// (Preferred interface is to instantiate an e107Mail object, then call sendEmail method with an array of parameters
|
||||
|
||||
// If $send_from is blank, uses the 'replyto' name and email if set, otherwise site admins details
|
||||
// $inline is a comma-separated list of embedded images to be included
|
||||
function sendemail($send_to, $subject, $message, $to_name, $send_from='', $from_name='', $attachments='', $Cc='', $Bcc='', $returnpath='', $returnreceipt='',$inline ='')
|
||||
/**
|
||||
* Function call to send an email
|
||||
*
|
||||
* Deprecated function
|
||||
*
|
||||
* Preferred method is to instantiate an e107MailManager object, and use the sendEmails() method, which also allows templates.
|
||||
*
|
||||
* see also sendTemplated() where non-default formating is required
|
||||
*
|
||||
* Note that plain text emails are converted to HTML, and also sent with a text part
|
||||
*
|
||||
* @param string $send_to - email address of recipient
|
||||
* @param string $subject
|
||||
* @param string $message
|
||||
* @param string $to_name
|
||||
* @param string $send_from - sender email address. (Defaults to the sitewide 'replyto' name and email if set, otherwise site admins details)
|
||||
* @param string $from_name - sender name. If $send_from is empty, defaults to the sitewide 'replyto' name and email if set, otherwise site admins details
|
||||
* @param string $attachments - comma-separated list of attachments
|
||||
* @param string $Cc - comma-separated list of 'copy to' email addresses
|
||||
* @param string $Bcc - comma-separated list of 'blind copy to' email addresses
|
||||
* @param string $returnpath - Sets 'reply to' email address
|
||||
* @param boolean $returnreceipt - TRUE to request receipt
|
||||
* @param string $inline - comma separated list of images to send inline
|
||||
*
|
||||
* @return boolean TRUE if send successfully (NOT an indication of receipt!), FALSE if error
|
||||
*/
|
||||
function sendemail($send_to, $subject, $message, $to_name='', $send_from='', $from_name='', $attachments='', $Cc='', $Bcc='', $returnpath='', $returnreceipt='',$inline ='')
|
||||
{
|
||||
global $mailheader_e107id;
|
||||
|
||||
|
||||
$overrides = array();
|
||||
// TODO: Find a way of doing this which doesn't use a global (or just ditch sendemail() )
|
||||
// Use defaults from email template?
|
||||
// ----- Mail pref. template override for parked domains, site mirrors or dynamic values
|
||||
global $EMAIL_OVERRIDES;
|
||||
if (isset($EMAIL_OVERRIDES) && is_array($EMAIL_OVERRIDES))
|
||||
|
@@ -2,25 +2,25 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2010 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* e107 Mailout - mail database API and utility routines
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/mail_manager_class.php,v $
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_handlers/redirection_class.php $
|
||||
* $Id: redirection_class.php 11922 2010-10-27 11:31:18Z secretr $
|
||||
* $Revision: 12125 $
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package e107
|
||||
* @subpackage e107_handlers
|
||||
* @version $Id$;
|
||||
* @version $Id: mail_manager_class.php 12125 2011-04-08 05:11:38Z e107coders $;
|
||||
*
|
||||
* @todo - consider whether to extract links in text-only emails
|
||||
* @todo - support separate template for the text part of emails
|
||||
|
||||
This class isolates the caller from the underlying database used to buffer and send emails.
|
||||
Also includes a number of useful routines
|
||||
@@ -72,16 +72,33 @@ mail_content - Details of the email to be sent to a number of people
|
||||
mail_last_date Don't send after this date/time
|
||||
mail_title A description of the mailout - not sent
|
||||
mail_subject Subject line
|
||||
mail_body Body text
|
||||
mail_body Body text - the 'raw' text as entered/specified by the user
|
||||
mail_body_templated Complete body text after applying the template, but before any variable substitutions
|
||||
mail_other Evaluates to an array of misc info - cc, bcc, attachments etc
|
||||
|
||||
mail_other constituents:
|
||||
mail_sender_email Sender's email address
|
||||
mail_sender_name Sender's name
|
||||
mail_copy_to Any recipients to copy
|
||||
mail_bcopy_to Any recipients to BCC
|
||||
mail_attach Comma-separated list of attachments
|
||||
mail_send_style Send style - HTML, text, template name etc
|
||||
mail_selectors Details of the selection criteria used for recipients (Only used internally)
|
||||
mail_include_images TRUE if to embed images, FALSE to add link to them
|
||||
mail_body_alt If non-empty, use for alternate email text (generally the 'plain text' alternative)
|
||||
mail_overrides If non-empty, any overrides for the mailer, set by the template
|
||||
|
||||
Within internal arrays, a flat structure is adopted. Variables relating to DB values all begin 'mail_' - others are internal (volatile) control variables
|
||||
|
||||
|
||||
Within internal arrays, a flat structure is adopted, with 'mail_other' merged with the rest of the 'mail_content' values.
|
||||
Variables relating to DB values all begin 'mail_' - others are internal (volatile) control variables
|
||||
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_mailout.php'); // May be needed by anything loading this class
|
||||
|
||||
define('MAIL_STATUS_SENT', 0); // Mail sent. Email handler happy, but may have bounced (or may be yet to bounce)
|
||||
define('MAIL_STATUS_BOUNCED', 1);
|
||||
define('MAIL_STATUS_CANCELLED', 2);
|
||||
@@ -115,8 +132,11 @@ class e107MailManager
|
||||
protected $queryCount = array(); // Stores total number of records if SQL_CALC_ROWS is used (index = db object #)
|
||||
protected $currentBatchInfo = array(); // Used during batch send to hold info about current mailout
|
||||
protected $currentMailBody = ''; // Buffers current mail body
|
||||
protected $currentTextBody = ''; // Alternative text body (if required)
|
||||
|
||||
protected $mailer = NULL; // Mailer class when required
|
||||
protected $mailOverrides = FALSE; // Any overrides to be passed to the mailer
|
||||
|
||||
|
||||
// Array defines DB types to be used
|
||||
protected $dbTypes = array(
|
||||
@@ -149,6 +169,7 @@ class e107MailManager
|
||||
'mail_title' => 'todb',
|
||||
'mail_subject' => 'todb',
|
||||
'mail_body' => 'todb',
|
||||
'mail_body_templated' => 'todb',
|
||||
'mail_other' => 'string' // Don't want entities here!
|
||||
)
|
||||
);
|
||||
@@ -160,6 +181,7 @@ class e107MailManager
|
||||
),
|
||||
'mail_content' => array(
|
||||
'mail_body' => '',
|
||||
'mail_body_templated' => '',
|
||||
'mail_other' => ''
|
||||
)
|
||||
);
|
||||
@@ -171,9 +193,11 @@ class e107MailManager
|
||||
'mail_copy_to' => 1,
|
||||
'mail_bcopy_to' => 1,
|
||||
'mail_attach' => 1,
|
||||
'mail_send_style' => 1,
|
||||
'mail_send_style' => 1, // HTML, text, template name etc
|
||||
'mail_selectors' => 1, // Only used internally
|
||||
'mail_include_images' => 1 // Used to determine whether to embed images, or link to them
|
||||
'mail_include_images' => 1, // Used to determine whether to embed images, or link to them
|
||||
'mail_body_alt' => 1, // If non-empty, use for alternate email text (generally the 'plain text' alternative)
|
||||
'mail_overrides' => 1
|
||||
);
|
||||
|
||||
// List of fields which are the status counts of an email, and their titles
|
||||
@@ -190,9 +214,10 @@ class e107MailManager
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($overrides = FALSE)
|
||||
{
|
||||
$this->e107 = e107::getInstance();
|
||||
$this->mailOverrides = $overrides;
|
||||
}
|
||||
|
||||
|
||||
@@ -269,18 +294,21 @@ class e107MailManager
|
||||
$res[$f] = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['mail_other']))
|
||||
{
|
||||
$array = new ArrayData;
|
||||
$tmp = $array->ReadArray($data['mail_other']);
|
||||
$tmp = $array->ReadArray(str_replace('\\\'', '\'',$data['mail_other'])); // May have escaped data
|
||||
if (is_array($tmp))
|
||||
{
|
||||
$res = array_merge($res,$tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res['Array_ERROR'] = 'No array found';
|
||||
}
|
||||
unset($res['mail_other']);
|
||||
}
|
||||
elseif ($addMissing)
|
||||
if ($addMissing)
|
||||
{
|
||||
foreach ($this->dbOther as $f => $v)
|
||||
{
|
||||
@@ -398,7 +426,7 @@ class e107MailManager
|
||||
$array = new ArrayData;
|
||||
if (isset($data['mail_other']))
|
||||
{
|
||||
$tmp = $array->ReadArray($data['mail_other']);
|
||||
$tmp = $array->ReadArray(str_replace('\\\'', '\'',$data['mail_other'])); // May have escaped data
|
||||
if (is_array($tmp))
|
||||
{
|
||||
$res = array_merge($res,$tmp);
|
||||
@@ -414,7 +442,7 @@ class e107MailManager
|
||||
}
|
||||
if (isset($data['mail_target_info']))
|
||||
{
|
||||
$tmp = $array->ReadArray($data['mail_target_info']);
|
||||
$tmp = $array->ReadArray(str_replace('\\\'', '\'',$data['mail_target_info'])); // May have escaped data
|
||||
$res['mail_target_info'] = $tmp;
|
||||
}
|
||||
return $res;
|
||||
@@ -434,7 +462,10 @@ class e107MailManager
|
||||
}
|
||||
|
||||
|
||||
// Internal function to create a db object for our use if none exists
|
||||
|
||||
/**
|
||||
* Internal function to create a db object for our use if none exists
|
||||
*/
|
||||
protected function checkDB($which = 1)
|
||||
{
|
||||
if (($which == 1) && ($this->db == NULL))
|
||||
@@ -448,7 +479,9 @@ class e107MailManager
|
||||
}
|
||||
|
||||
|
||||
// Internal function to create a mailer object for our use if none exists
|
||||
/**
|
||||
* Internal function to create a mailer object for our use if none exists
|
||||
*/
|
||||
protected function checkMailer()
|
||||
{
|
||||
if ($this->mailer != NULL) return;
|
||||
@@ -456,13 +489,29 @@ class e107MailManager
|
||||
{
|
||||
require_once(e_HANDLER.'mail.php');
|
||||
}
|
||||
$this->mailer = new e107Email; // Could add in overrides here
|
||||
$this->mailer = new e107Email($this->mailOverrides);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert numeric represntation of mail status to a text string
|
||||
* Set the override values for the mailer object.
|
||||
*
|
||||
* @param array $overrides - see mail.php for details of accepted values
|
||||
*
|
||||
* @return boolean TRUE if accepted, FALSE if rejected
|
||||
*/
|
||||
public function setMailOverrides($overrides)
|
||||
{
|
||||
if ($this->mailer != NULL) return FALSE; // Mailer already created - it's too late!
|
||||
$this->mailOverrides = $overrides;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert numeric representation of mail status to a text string
|
||||
*
|
||||
* @param integer $status - numeric value of status
|
||||
* @return string text value
|
||||
@@ -532,7 +581,7 @@ class e107MailManager
|
||||
|
||||
|
||||
/**
|
||||
* Get next email from selection
|
||||
* Get next email from selection (usually from selectEmails() )
|
||||
* @return Returns array of email data if available - FALSE if no further data, no active query, or other error
|
||||
*/
|
||||
public function getNextEmail()
|
||||
@@ -545,7 +594,6 @@ class e107MailManager
|
||||
{
|
||||
$this->queryActive--;
|
||||
return $this->dbToBoth($result);
|
||||
// return array_merge($this->dbToMail($result), $this->dbToTarget($result));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -569,6 +617,8 @@ class e107MailManager
|
||||
* Call to send next email from selection
|
||||
*
|
||||
* @return Returns TRUE if successful, FALSE on fail (or no more to go)
|
||||
*
|
||||
* @todo Could maybe save parsed page in cache if more than one email to go
|
||||
*/
|
||||
public function sendNextEmail()
|
||||
{
|
||||
@@ -579,6 +629,10 @@ class e107MailManager
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* The $email variable has all the email data in 'flat' form, including that of the current recipient.
|
||||
* field $email['mail_target_info'] has variable substitution information relating to the current recipient
|
||||
*/
|
||||
if (count($this->currentBatchInfo))
|
||||
{
|
||||
//print_a($this->currentBatchInfo);
|
||||
@@ -587,6 +641,7 @@ class e107MailManager
|
||||
//echo "New email body: {$this->currentBatchInfo['mail_source_id']} != {$email['mail_source_id']}<br />";
|
||||
$this->currentBatchInfo = array(); // New source email - clear stored info
|
||||
$this->currentMailBody = ''; // ...and clear cache for message body
|
||||
$this->currentTextBody = '';
|
||||
}
|
||||
}
|
||||
if (count($this->currentBatchInfo) == 0)
|
||||
@@ -615,45 +670,23 @@ class e107MailManager
|
||||
|
||||
if (!$this->currentMailBody)
|
||||
{
|
||||
$this->currentMailBody = $this->makeEmailBody($email['mail_body'], $email['mail_send_style'], varset($email['mail_include_images'], FALSE));
|
||||
}
|
||||
// Do any substitutions
|
||||
$search = array();
|
||||
$replace = array();
|
||||
foreach ($email['mail_target_info'] as $k => $v)
|
||||
if (isset($email['mail_body_templated']))
|
||||
{
|
||||
$search[] = '|'.$k.'|';
|
||||
$replace[] = $v;
|
||||
}
|
||||
$email['mail_body'] = str_replace($search, $replace, $this->currentMailBody);
|
||||
$email['send_html'] = ($email['mail_send_style'] != 'textonly');
|
||||
|
||||
// Set up any extra mailer parameters that need it
|
||||
if (!vartrue($email['e107_header']))
|
||||
{
|
||||
$temp = intval($email['mail_recipient_id']).'/'.intval($email['mail_source_id']).'/'.intval($email['mail_target_id']).'/';
|
||||
$email['e107_header'] = $temp.md5($temp); // Set up an ID
|
||||
}
|
||||
if (isset($email['mail_attach']) && (trim($email['mail_attach']) || is_array($email['mail_attach'])))
|
||||
{
|
||||
$downDir = realpath(e_ROOT.$this->e107->getFolder('downloads'));
|
||||
if (is_array($email['mail_attach']))
|
||||
{
|
||||
foreach ($email['mail_attach'] as $k => $v)
|
||||
{
|
||||
$email['mail_attach'][$k] = $downDir.$v;
|
||||
}
|
||||
$this->currentMailBody = $email['mail_body_templated'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$email['mail_attach'] = $downDir.$email['mail_attach'];
|
||||
$this->currentMailBody = $email['mail_body'];
|
||||
}
|
||||
$this->currentTextBody = $email['mail_body_alt']; // May be null
|
||||
}
|
||||
|
||||
$mailToSend = $this->makeEmailBlock($email); // Substitute mail-specific variables, attachments etc
|
||||
|
||||
// print_a($email);
|
||||
|
||||
// Try and send
|
||||
$result = $this->mailer->sendEmail($email['mail_recipient_email'], $email['mail_recipient_name'], $email, TRUE);
|
||||
$result = $this->mailer->sendEmail($email['mail_recipient_email'], $email['mail_recipient_name'], $mailToSend, TRUE);
|
||||
|
||||
// return; // ************************************************** Temporarily stop DB being updated when line active *****************************
|
||||
|
||||
@@ -744,6 +777,84 @@ class e107MailManager
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Given an email block, creates an array of data compatible with PHPMailer, including any necessary substitutions
|
||||
*/
|
||||
protected function makeEmailBlock($email)
|
||||
{
|
||||
$mailSubsInfo = array(
|
||||
'email_subject' => 'mail_subject',
|
||||
'email_sender_email' => 'mail_sender_email',
|
||||
'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.
|
||||
//'email_cc_names' - comma-separated list of cc names. Optional, used only if $eml['email_copy_to'] specified
|
||||
'email_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)
|
||||
//'email_inline_images' - array of files for inline images
|
||||
//'priority' - Email priority (1 = High, 3 = Normal, 5 = low)
|
||||
//'extra_header' - additional headers (format is name: value
|
||||
//'wordwrap' - Set wordwrap value
|
||||
//'split' - If true, sends an individual email to each recipient
|
||||
);
|
||||
$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];
|
||||
}
|
||||
}
|
||||
|
||||
// Do any substitutions
|
||||
$search = array();
|
||||
$replace = array();
|
||||
foreach ($email['mail_target_info'] as $k => $v)
|
||||
{
|
||||
$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
|
||||
if (!vartrue($email['e107_header']))
|
||||
{
|
||||
$temp = intval($email['mail_recipient_id']).'/'.intval($email['mail_source_id']).'/'.intval($email['mail_target_id']).'/';
|
||||
$result['e107_header'] = $temp.md5($temp); // Set up an ID
|
||||
}
|
||||
if (isset($email['mail_attach']) && (trim($email['mail_attach']) || is_array($email['mail_attach'])))
|
||||
{
|
||||
$downDir = realpath(e_ROOT.$this->e107->getFolder('downloads'));
|
||||
if (is_array($email['mail_attach']))
|
||||
{
|
||||
foreach ($email['mail_attach'] as $k => $v)
|
||||
{
|
||||
$result['email_attach'][$k] = $downDir.$v;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result['email_attach'] = $downDir.trim($email['mail_attach']);
|
||||
}
|
||||
}
|
||||
if (isset($email['mail_overrides']) && is_array($email['mail_overrides'])) $result = array_merge($result, $email['mail_overrides']);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Call to do a number of 'units' of email processing - from a cron job, for example
|
||||
* Each 'unit' sends one email from the queue - potentially it could do some other task.
|
||||
@@ -1314,71 +1425,171 @@ class e107MailManager
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates email body text according to options
|
||||
* @param $text string - text to process
|
||||
* @param $format string - options:
|
||||
* textonly - generate plain text email
|
||||
* texthtml - HTML format email, no theme info
|
||||
* texttheme - HTML format email, including current theme stylesheet etc
|
||||
* @param boolean $incImages - valid only with HTML output;
|
||||
* if true any 'absolute' format images are embedded in the source of the email.
|
||||
* if FALSE, absolute links are converted to URLs on the local server
|
||||
* @return string - updated body
|
||||
//-----------------------------------------------------
|
||||
// Function call to send a templated email
|
||||
//-----------------------------------------------------
|
||||
|
||||
/**
|
||||
* Send an email to any number of recipients, using a template
|
||||
*
|
||||
* The template may contain normal shortcodes, which must already have been loaded. @see e107_themes/email_template.php
|
||||
*
|
||||
* The template (or other body text) may also contain field names in the form |USER_NAME| (as used in the bulk mailer edit page). These are
|
||||
* filled in from $templateData - field name corresponds to the array index name (case-sensitive)
|
||||
*
|
||||
* The template definition may contain an array $template['email_overrides'] of values which override normal mailer settings.
|
||||
*
|
||||
* The template definition MUST contain a template variable $template['email_body']
|
||||
*
|
||||
* In general, any template definition which isn't overridden uses the default which should be specified in e_THEME.'templates/email_templates.php'
|
||||
*
|
||||
* There is a presumption that the email is being templated because it contains HTML, although this isn't mandatory.
|
||||
*
|
||||
* Any language string constants required in the template must be defined either by loading the requisite language file prior to calling this
|
||||
* routine, or by loading them in the template file.
|
||||
*
|
||||
* @param array|string $templateName - if a string, the name of the template - information is loaded from theme and default templates.
|
||||
* - if an array, template data as returned by gettemplateInfo() (and defined in the template files)
|
||||
* - if empty, sends a simple email using the default template (much as the original sendemail() function in mail.php)
|
||||
* @param array $emailData - defines the email information (generally as the 'mail_content' and 'mail_other' info above):
|
||||
* $emailData = array(
|
||||
'mail_create_app' => 'notify',
|
||||
'mail_title' => 'NOTIFY',
|
||||
'mail_subject' => $subject,
|
||||
'mail_sender_email' => $pref['siteadminemail'],
|
||||
'mail_sender_name' => $pref['siteadmin'],
|
||||
'mail_send_style' => 'textonly',
|
||||
'mail_notify_complete' => 0, // NEVER notify when this email sent!!!!!
|
||||
'mail_body' => $message
|
||||
);
|
||||
* @param array|string $recipientData - if a string, its the email address of a single recipient.
|
||||
* - if an array, each entry is the data for a single recipient, as the 'mail_recipients' definition above
|
||||
* $recipientData = array('mail_recipient_id' => $row['user_id'],
|
||||
'mail_recipient_name' => $row['user_name'],
|
||||
'mail_recipient_email' => $row['user_email']
|
||||
);
|
||||
* ....and other data as appropriate
|
||||
* @param boolean|array $extra - any additional parameters to be passed to the mailer - as accepted by arraySet method.
|
||||
* These parameters will override any defaults, and any set in the template
|
||||
* if ($extra['mail_force_queue'] is TRUE, the mail will be added to the queue regardless of the number of recipients
|
||||
*
|
||||
* @return boolean TRUE if either added to queue, or sent, successfully (does NOT indicate receipt). FALSE on any error
|
||||
* (Note that with a small number of recipients FALSE indicates that one or more emails weren't sent - some may have been sent successfully)
|
||||
*/
|
||||
protected function makeEmailBody($text, $format = 'textonly', $incImages = TRUE)
|
||||
|
||||
public function sendEmails($templateName, $emailData, $recipientData, $extra = FALSE)
|
||||
{
|
||||
global $pref;
|
||||
if ($format == 'textonly')
|
||||
{ // Plain text email - strip bbcodes etc
|
||||
$temp = $this->e107->tp->toHTML($text, TRUE, 'E_BODY_PLAIN'); // Decode bbcodes into HTML, plain text as far as possible etc
|
||||
return stripslashes(strip_tags($temp)); // Have to do strip_tags() again in case bbcode added some
|
||||
if (!is_array($emailData)) return FALSE;
|
||||
if (!is_array($recipientData))
|
||||
{
|
||||
$recipientData = array('mail_recipient_email' => $recipientData, 'mail_recipient_name' => $recipientData);
|
||||
}
|
||||
$emailData['mail_content_status'] = MAIL_STATUS_TEMP;
|
||||
|
||||
if ($templateName == '')
|
||||
{
|
||||
$templateName = varset($email['mail_send_style'], 'textonly'); // Safest default if nothing specified
|
||||
}
|
||||
$templateName = trim($templateName);
|
||||
if ($templateName == '') return FALSE;
|
||||
|
||||
|
||||
// Get template data, override email settings as appropriate
|
||||
require_once(e_HANDLER.'mail_template_class.php');
|
||||
$ourTemplate = new e107MailTemplate();
|
||||
if (!$ourTemplate->setNewTemplate($templateName)) return FALSE; // Probably template not found if error
|
||||
if (!$ourTemplate->makeEmailBody($emailData['mail_body'], varset($emailData['mail_include_images'], TRUE))) return FALSE; // Create body text
|
||||
$emailData['mail_body_templated'] = $ourTemplate->mainBodyText;
|
||||
$this->currentMailBody = $emailData['mail_body_templated']; // In case we send immediately
|
||||
$emailData['mail_body_alt'] = $ourTemplate->altBodyText;
|
||||
$this->currentTextBody = $emailData['mail_body_alt'];
|
||||
if (!isset($emailData['mail_overrides']))
|
||||
{
|
||||
$emailData['mail_overrides'] = $ourTemplate->lastTemplateData['email_overrides'];
|
||||
}
|
||||
|
||||
$consts = $incImages ? ',consts_abs' : 'consts_full'; // If inline images, absolute constants so we can change them
|
||||
|
||||
// HTML format email here
|
||||
$mail_head = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
|
||||
$mail_head .= "<html xmlns='http://www.w3.org/1999/xhtml' >\n";
|
||||
$mail_head .= "<head><meta http-equiv='content-type' content='text/html; charset=utf-8' />\n";
|
||||
if ($format == 'texttheme')
|
||||
$forceQueue = FALSE;
|
||||
if (is_array($extra) && isset($extra['mail_force_queue']))
|
||||
{
|
||||
$styleFile = THEME.'emailstyle.css';
|
||||
if (!is_readable($styleFile)) { $styleFile = e_THEME.$pref['sitetheme']."/style.css"; }
|
||||
$style_css = file_get_contents($styleFile);
|
||||
$mail_head .= "<style>\n".$style_css."\n</style>";
|
||||
$forceQueue = $extra['mail_force_queue'];
|
||||
unset($extra['mail_force_queue']);
|
||||
}
|
||||
$mail_head .= "</head>\n";
|
||||
|
||||
|
||||
$message_body = $mail_head."<body>\n";
|
||||
if ($format == 'texttheme')
|
||||
if ((count($recipientData) <= 5) && !$forceQueue) // Arbitrary upper limit for sending multiple emails immediately
|
||||
{
|
||||
$message_body .= "<div style='padding:10px;width:97%'><div class='forumheader3'>\n";
|
||||
$message_body .= $this->e107->tp->toHTML($text, TRUE, 'E_BODY'.$consts)."</div></div></body></html>";
|
||||
if ($this->mailer == NULL)
|
||||
{
|
||||
e107_require_once(e_HANDLER.'mail.php');
|
||||
$this->mailer = new e107Email($extra);
|
||||
}
|
||||
$tempResult = TRUE;
|
||||
$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))
|
||||
{
|
||||
$tempResult = FALSE;
|
||||
}
|
||||
else
|
||||
{ // Success here
|
||||
if ($eCount == 0)
|
||||
{ // Only send these on first email - otherwise someone could get inundated!
|
||||
unset($emailData['mail_copy_to']);
|
||||
unset($emailData['mail_bcopy_to']);
|
||||
}
|
||||
$eCount++; // Count number of successful emails sent
|
||||
}
|
||||
}
|
||||
return $tempResult;
|
||||
}
|
||||
|
||||
// To many recipients to send at once - add to the emailing queue
|
||||
// @TODO - handle any other relevant $extra fields
|
||||
$result = $this->saveEmail($emailData, TRUE);
|
||||
if ($result === FALSE)
|
||||
{
|
||||
// TODO: Handle error
|
||||
return FALSE; // Probably nothing else we can do
|
||||
}
|
||||
elseif (is_numeric($result))
|
||||
{
|
||||
$mailMainID = $emailData['mail_source_id'] = $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$message_body .= $this->e107->tp->toHTML($text, TRUE, 'E_BODY'.$consts)."</body></html>";
|
||||
$message_body = str_replace(""", '"', $message_body);
|
||||
// TODO: Handle strange error
|
||||
return FALSE; // Probably nothing else we can do
|
||||
}
|
||||
$this->mailInitCounters($mailMainID); // Initialise counters for emails added
|
||||
|
||||
$message_body = stripslashes($message_body);
|
||||
|
||||
|
||||
if (!$incImages)
|
||||
// Now add email addresses to the list
|
||||
foreach ($recipientData as $email)
|
||||
{
|
||||
// Handle internally generated 'absolute' links - they need the full URL
|
||||
$message_body = str_replace("src='".e_HTTP, "src='".SITEURL, $message_body);
|
||||
$message_body = str_replace('src="'.e_HTTP, 'src="'.SITEURL, $message_body);
|
||||
$message_body = str_replace("href='".e_HTTP, "src='".SITEURL, $message_body);
|
||||
$message_body = str_replace('href="'.e_HTTP, 'src="'.SITEURL, $message_body);
|
||||
$result = $this->mailAddNoDup($mailMainID, $email, MAIL_STATUS_TEMP);
|
||||
}
|
||||
|
||||
// print_a($message_body);
|
||||
return $message_body;
|
||||
$this->mailUpdateCounters($mailMainID); // Update the counters
|
||||
$counters = $this->mailRetrieveCounters($mailMainID); // Retrieve the counters
|
||||
if ($counters['add'] == 0)
|
||||
{
|
||||
$this->deleteEmail($mailMainID); // Probably a fault, but precautionary - delete email
|
||||
// Don't treat as an error if no recipients
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->activateEmail($mailMainID, FALSE); // Actually mark the email for sending
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
@@ -2,25 +2,25 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2010 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* Mailout - admin-related functions
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/mailout_admin_class.php,v $
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $Revision: 12775 $
|
||||
* $Date: 2012-06-01 09:09:14 +0100 (Fri, 01 Jun 2012) $
|
||||
* $Author: e107coders $
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Various admin-related mailout functions, mostly to do with creating and handling forms.
|
||||
*
|
||||
* @package e107
|
||||
* @subpackage e107_handlers
|
||||
* @version $Id$;
|
||||
* @version $Id: mailout_admin_class.php 12775 2012-06-01 08:09:14Z e107coders $;
|
||||
*/
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ TODO:
|
||||
1. Use API to downloads plugin to get available files (when available)
|
||||
2. Fuller checking prior to send
|
||||
3. May want more control over date display format
|
||||
4. Use new date picker
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
@@ -85,6 +86,7 @@ class mailoutAdminClass extends e107MailManager
|
||||
'mail_notify_complete' => array('title' => LAN_MAILOUT_243, 'nolist' => 'TRUE'),
|
||||
'mail_last_date' => array('title' => LAN_MAILOUT_129, 'proc' => 'sdatetime'),
|
||||
'mail_body' => array('title' => LAN_MAILOUT_100, 'proc' => 'trunc200'),
|
||||
'mail_body_templated' => array('title' => LAN_MAILOUT_257, 'proc' => 'chars'),
|
||||
// 'mail_other' = array('title' => LAN_MAILOUT_84),
|
||||
'mail_sender_email' => array('title' => LAN_MAILOUT_149),
|
||||
'mail_sender_name' => array('title' => LAN_MAILOUT_150),
|
||||
@@ -125,11 +127,12 @@ class mailoutAdminClass extends e107MailManager
|
||||
);
|
||||
|
||||
|
||||
// Options for mail listing dropdown
|
||||
// Options for mail listing dropdown - actions apertaining to a stored email
|
||||
protected $modeOptions = array(
|
||||
'saved' => array(
|
||||
'mailedit' => LAN_MAILOUT_163,
|
||||
'maildelete' => LAN_DELETE
|
||||
'maildelete' => LAN_DELETE,
|
||||
'mailshowtemplate' => LAN_MAILOUT_254
|
||||
),
|
||||
'pending' => array(
|
||||
'mailsendimmediately' => "Send Immediately",
|
||||
@@ -156,7 +159,8 @@ class mailoutAdminClass extends e107MailManager
|
||||
// List of fields to be included in email display for various options
|
||||
protected $mailDetailDisplay = array(
|
||||
'basic' => array('mail_source_id' => 1, 'mail_title' => 1, 'mail_subject' => 1, 'mail_body' => 200),
|
||||
'send' => array('mail_source_id' => 1, 'mail_title' => 1, 'mail_subject' => 1, 'mail_body' => 500)
|
||||
'send' => array('mail_source_id' => 1, 'mail_title' => 1, 'mail_subject' => 1, 'mail_body' => 500, 'mail_send_style' => 1),
|
||||
'template' => array('mail_source_id' => 1, 'mail_title' => 1, 'mail_subject' => 1, 'mail_body' => 200, 'mail_body_templated' => 'chars'),
|
||||
);
|
||||
|
||||
|
||||
@@ -169,8 +173,6 @@ class mailoutAdminClass extends e107MailManager
|
||||
public function __construct($mode = '')
|
||||
{
|
||||
parent::__construct();
|
||||
// require_once(e_HANDLER.'calendar/calendar_class.ph_');
|
||||
// $this->_cal = new DHTML_Calendar(true);
|
||||
|
||||
$dbTable = '';
|
||||
if (isset($this->tasks[$mode]))
|
||||
@@ -350,10 +352,12 @@ class mailoutAdminClass extends e107MailManager
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generate the HTML for displaying actions box for emails
|
||||
*
|
||||
* Options given depend on $mode, and also values in the email data.
|
||||
* Options given depend on $mode (saved|sent|pending|held), and also values in the email data.
|
||||
*
|
||||
* @param array $mailData - array of email-related info
|
||||
* @return string HTML for display
|
||||
@@ -552,6 +556,8 @@ class mailoutAdminClass extends e107MailManager
|
||||
* @param string $name - name for <select>
|
||||
* @param string $curSel - current select value
|
||||
* @return text for display
|
||||
*
|
||||
* @TODO: Doesn't give correct count for core classes where no data initialised
|
||||
*/
|
||||
public function userClassesTotals($name, $curSel)
|
||||
{
|
||||
@@ -570,6 +576,7 @@ class mailoutAdminClass extends e107MailManager
|
||||
$query = "SELECT uc.*, count(u.user_id) AS members
|
||||
FROM #userclass_classes AS uc
|
||||
LEFT JOIN #user AS u ON u.user_class REGEXP concat('(^|,)',uc.userclass_id,'(,|$)')
|
||||
WHERE NOT uc.userclass_id IN (".e_UC_PUBLIC.','.e_UC_NOBODY.','.e_UC_READONLY.','.e_UC_BOTS.")
|
||||
GROUP BY uc.userclass_id
|
||||
";
|
||||
|
||||
@@ -593,11 +600,12 @@ class mailoutAdminClass extends e107MailManager
|
||||
* @param string $list_name - name for <select>
|
||||
* @param string $curval - current select value
|
||||
* @param boolean $add_blank - add a blank line before the options if TRUE
|
||||
* @return text for display
|
||||
* @return text for display if any extended fields defined; FALSE if none available
|
||||
*/
|
||||
public function ret_extended_field_list($list_name, $curval = '', $add_blank = FALSE)
|
||||
{
|
||||
$ue = e107::getUserExt(); // Get the extended field handler
|
||||
if (count($ue->fieldDefinitions) == 0) return FALSE;
|
||||
$ret = "<select name='{$list_name}' class='tbox'>\n";
|
||||
if ($add_blank) $ret .= "<option value=''> </option>\n";
|
||||
|
||||
@@ -634,8 +642,8 @@ class mailoutAdminClass extends e107MailManager
|
||||
'mail_copy_to' => $_POST['email_cc'],
|
||||
'mail_bcopy_to' => $_POST['email_bcc'],
|
||||
'mail_attach' => trim($_POST['email_attachment']),
|
||||
'mail_send_style' => varset($_POST['send_style'],'textonly'),
|
||||
'mail_include_images' => (isset($_POST['mail_include_images']) ? 1 : 0)
|
||||
'mail_send_style' => varset($_POST['email_send_style'],'textonly'),
|
||||
'mail_include_images' => (isset($_POST['email_include_images']) ? 1 : 0)
|
||||
);
|
||||
|
||||
$ret = $tp->toDB($ret); // recursive
|
||||
@@ -661,7 +669,7 @@ class mailoutAdminClass extends e107MailManager
|
||||
* @param $fullCheck - TRUE to check all fields that are required (immediately prior to sending); FALSE to just check a few basics (prior to save)
|
||||
* @return TRUE if OK. Array of error messages if any errors found
|
||||
*/
|
||||
public function checkEmailPost($email, $fullCheck = FALSE)
|
||||
public function checkEmailPost(&$email, $fullCheck = FALSE)
|
||||
{
|
||||
$errList = array();
|
||||
if (count($email) < 3)
|
||||
@@ -673,15 +681,38 @@ class mailoutAdminClass extends e107MailManager
|
||||
if (!trim($email['mail_body'])) $errList[] = LAN_MAILOUT_202;
|
||||
if (!trim($email['mail_sender_name'])) $errList[] = LAN_MAILOUT_203;
|
||||
if (!trim($email['mail_sender_email'])) $errList[] = LAN_MAILOUT_204;
|
||||
switch ($email['mail_send_style'])
|
||||
{
|
||||
case 'textonly' :
|
||||
case 'texthtml' :
|
||||
case 'texttheme' :
|
||||
break;
|
||||
default :
|
||||
if (strlen($email['mail_send_style']) == 0)
|
||||
{ // Can be a template name now
|
||||
$errList[] = LAN_MAILOUT_205;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get template data, override email settings as appropriate
|
||||
require_once(e_HANDLER.'mail_template_class.php');
|
||||
$ourTemplate = new e107MailTemplate();
|
||||
$templateName = $email['mail_send_style'];
|
||||
if (!$ourTemplate->setNewTemplate($templateName))
|
||||
{
|
||||
$errList[] = LAN_MAILOUT_207.':'.$templateName;
|
||||
print_a($ourTemplate); // Probably template not found if error
|
||||
}
|
||||
if (!$ourTemplate->makeEmailBody($email['mail_body'], $email['mail_include_images']))
|
||||
{
|
||||
$errList[] = LAN_MAILOUT_205.':'.$templateName;
|
||||
print_a($ourTemplate);
|
||||
}
|
||||
else
|
||||
{
|
||||
$email['mail_body_templated'] = $ourTemplate->mainBodyText;
|
||||
$email['mail_body_alt'] = $ourTemplate->altBodyText;
|
||||
if (count($ourTemplate->lastTemplateData['email_overrides']))
|
||||
{
|
||||
$email['mail_overrides'] = $ourTemplate->lastTemplateData['email_overrides'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($errList) == 0)
|
||||
{
|
||||
return TRUE;
|
||||
@@ -709,14 +740,48 @@ class mailoutAdminClass extends e107MailManager
|
||||
return "<tr><td colspan='2'>Programming bungle - invalid option value: {$options}</td></tr>";
|
||||
}
|
||||
|
||||
$res = '';
|
||||
$text = '';
|
||||
foreach ($this->mailDetailDisplay[$options] as $k => $v)
|
||||
{
|
||||
$res .= '<tr><td>'.$this->fields['mail_content'][$k]['title'].'</td><td>';
|
||||
$res .= ($v > 1) ? $tp->text_truncate($mailSource[$k], $v, '...') : $mailSource[$k];
|
||||
$res .= '</td></tr>'."\n";
|
||||
$text .= '<tr><td>'.$this->fields['mail_content'][$k]['title'].'</td><td>';
|
||||
$val = $mailSource[$k];
|
||||
if (is_numeric($v))
|
||||
{
|
||||
$text .= ($v > 1) ? $tp->text_truncate($val, $v, '...') : $val;
|
||||
}
|
||||
return $res;
|
||||
else
|
||||
{
|
||||
switch ($v)
|
||||
{
|
||||
case 'username' :
|
||||
$text .= $this->getUserName($val);
|
||||
break;
|
||||
case 'sdatetime' :
|
||||
$text .= $gen->convert_date($val, 'short');
|
||||
break;
|
||||
case 'trunc200' :
|
||||
$text .= $this->e107->tp->text_truncate($val, 200, '...');
|
||||
break;
|
||||
case 'chars' : // Show generated html as is
|
||||
$text .= htmlspecialchars($val, ENT_COMPAT, 'UTF-8');
|
||||
break;
|
||||
case 'contentstatus' :
|
||||
$text .= $this->statusToText($val);
|
||||
break;
|
||||
case 'selectors' :
|
||||
$text .= 'cannot display';
|
||||
break;
|
||||
case 'yesno' :
|
||||
$text .= $val ? LAN_YES : LAN_NO;
|
||||
break;
|
||||
case 'default' :
|
||||
default :
|
||||
$text .= $val;
|
||||
}
|
||||
}
|
||||
$text .= '</td></tr>'."\n";
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
@@ -729,7 +794,7 @@ class mailoutAdminClass extends e107MailManager
|
||||
* @return text for display
|
||||
*/
|
||||
//FIXME use $frm->selectbox() instead.
|
||||
public function sendStyleSelect($curval = '', $name = 'send_style')
|
||||
public function sendStyleSelect($curval = '', $name = 'email_send_style', $incTemplates = TRUE)
|
||||
{
|
||||
|
||||
$emFormat = array(
|
||||
@@ -745,6 +810,15 @@ class mailoutAdminClass extends e107MailManager
|
||||
$selected = ($key == $curval) ? " selected='selected'" : '';
|
||||
$text .= "<option value='".$key."'{$selected}>".$val."</option>\n";
|
||||
}
|
||||
if ($incTemplates)
|
||||
{
|
||||
$tList = self::getEmailTemplateNames('user');
|
||||
foreach ($tList as $key=>$val)
|
||||
{
|
||||
$selected = ($key == $curval) ? " selected='selected'" : '';
|
||||
$text .= "<option value='".$key."'{$selected}>".LAN_MAILOUT_258.$val."</option>\n";
|
||||
}
|
||||
}
|
||||
$text .="</select>\n";
|
||||
return $text;
|
||||
}
|
||||
@@ -891,7 +965,7 @@ class mailoutAdminClass extends e107MailManager
|
||||
|
||||
$text .= $this->sendStyleSelect(varset($mailSource['mail_send_style'], ''));
|
||||
$checked = (isset($mailSource['mail_include_images']) && $mailSource['mail_include_images']) ? " checked='checked'" : '';
|
||||
$text .= " <input type='checkbox' name='mail_include_images' value='1' {$checked} />".LAN_MAILOUT_225;
|
||||
$text .= " <input type='checkbox' name='email_include_images' value='1' {$checked} />".LAN_MAILOUT_225;
|
||||
$text .="
|
||||
</td></tr>\n
|
||||
<tr>
|
||||
@@ -946,7 +1020,11 @@ class mailoutAdminClass extends e107MailManager
|
||||
}
|
||||
|
||||
|
||||
// Helper function manages the shortcodes which can be inserted
|
||||
|
||||
|
||||
/**
|
||||
* Helper function manages the shortcodes which can be inserted
|
||||
*/
|
||||
function sc_Select($container='sc_selector')
|
||||
{
|
||||
$text ="
|
||||
@@ -1003,6 +1081,49 @@ class mailoutAdminClass extends e107MailManager
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show the generated template of a saved email
|
||||
*/
|
||||
public function showEmailTemplate($mailId)
|
||||
{
|
||||
$mailData = $this->retrieveEmail($mailId);
|
||||
|
||||
$text = "<div style='text-align:center'>";
|
||||
|
||||
if ($mailData === FALSE)
|
||||
{
|
||||
$text = "<div class='forumheader2' style='text-align:center'>".LAN_MAILOUT_79.'</div></div>';
|
||||
$this->e107->ns-> tablerender("<div style='text-align:center'>".LAN_MAILOUT_171."</div>", $text);
|
||||
exit;
|
||||
}
|
||||
|
||||
$text .= "
|
||||
<form action='".e_SELF."?mode=saved' id='email_show_template' method='post'>
|
||||
<fieldset id='email-show-template'>
|
||||
<table class='table adminlist'>
|
||||
<colgroup>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
</colgroup>
|
||||
<tbody>";
|
||||
|
||||
$text .= $this->showMailDetail($mailData, 'template');
|
||||
$text .= '<tr><td>'.LAN_MAILOUT_172.'</td><td>'.$this->statusToText($mailData['mail_content_status'])."<input type='hidden' name='mailIDConf' value='{$mailID}' /></td></tr>";
|
||||
|
||||
$text .= "</tbody></table>\n</fieldset>";
|
||||
|
||||
$text .= "<div class='buttons-bar center'>
|
||||
<input class='btn button' type='submit' name='email_delete' value=\"".LAN_MAILOUT_256."\" />
|
||||
</div>";
|
||||
|
||||
$text .= "</form></div>";
|
||||
$this->e107->ns->tablerender("<div style='text-align:center'>".ADLAN_136." :: ".LAN_MAILOUT_255.$mailId.'</div>', $text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show a screen to confirm deletion of an email
|
||||
*
|
||||
@@ -1057,7 +1178,7 @@ class mailoutAdminClass extends e107MailManager
|
||||
/**
|
||||
* Generate the HTML to show a list of emails of a particular type, in tabular form
|
||||
*
|
||||
* @param $type - type of email to display
|
||||
* @param $type - type of email to display (saved|sent|pending|held)
|
||||
* @param $from - offset into table of candidates
|
||||
* @param $amount - number to return
|
||||
* @return text for display
|
||||
@@ -1124,6 +1245,9 @@ class mailoutAdminClass extends e107MailManager
|
||||
case 'trunc200' :
|
||||
$text .= $this->e107->tp->text_truncate($row[$fieldName], 200, '...');
|
||||
break;
|
||||
case 'chars' : // Show generated html as is
|
||||
$text .= htmlspecialchars($row[$fieldName], ENT_COMPAT, 'UTF-8');
|
||||
break;
|
||||
case 'contentstatus' :
|
||||
$text .= $this->statusToText($row[$fieldName]);
|
||||
break;
|
||||
@@ -1166,7 +1290,7 @@ class mailoutAdminClass extends e107MailManager
|
||||
* Generate a list of emails to send
|
||||
* Returns various information to display in a confirmation screen
|
||||
*
|
||||
* The email and its recipients are stored in the DB with a tag of 'MAIL_STATUS_TEMP' of its a new email (no change if already on hold)
|
||||
* The email and its recipients are stored in the DB with a tag of 'MAIL_STATUS_TEMP' if its a new email (no change if already on hold)
|
||||
*
|
||||
* @param array $mailData - Details of the email, selection criteria etc
|
||||
* @param boolean $fromHold - FALSE if this is a 'new' email to send, TRUE if its already been put on hold (selects processing path)
|
||||
@@ -1300,6 +1424,10 @@ class mailoutAdminClass extends e107MailManager
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function makeAdvancedOptions($initHide = FALSE)
|
||||
{
|
||||
// Separate table for advanced mailout options
|
||||
@@ -1326,46 +1454,39 @@ class mailoutAdminClass extends e107MailManager
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function makeCalendar($calName, $calVal = '', $dateOrder = 'dmy')
|
||||
{
|
||||
// Determine formatting strings this way, to give sensible default
|
||||
switch ($dateOrder)
|
||||
{
|
||||
case 'mdy' :
|
||||
$dateString = '%m/%d/%Y %H:%I';
|
||||
$dispString = 'm/d/Y H:I';
|
||||
$dFormat = '%m/%d/%y';
|
||||
$tFormat = '%H:%M';
|
||||
break;
|
||||
case 'ymd' :
|
||||
$dateString = '%Y/%m/%d %H:%I';
|
||||
$dispString = 'Y/m/d H:I';
|
||||
$dFormat = '%Y/%m/%d';
|
||||
$tFormat = ' %H:%M';
|
||||
break;
|
||||
case 'dmy' :
|
||||
default :
|
||||
$dateString = '%d/%m/%Y %H:%I';
|
||||
$dispString = 'd/m/Y H:I';
|
||||
$dFormat = '%d/%m/%Y';
|
||||
$tFormat = ' %H:%M';
|
||||
}
|
||||
$calOptions = array(
|
||||
'showsTime' => TRUE,
|
||||
'showOthers' => false,
|
||||
'weekNumbers' => false,
|
||||
'ifFormat' => $dateString
|
||||
);
|
||||
$calAttrib = array(
|
||||
'class' => 'tbox',
|
||||
'size' => 15, // Number of characters
|
||||
'name' => $calName,
|
||||
'value' => (($calVal == '') ? '' : date($dispString,$calVal))
|
||||
);
|
||||
|
||||
|
||||
list($dformat,$tformat) = explode(" ",$dateString);
|
||||
$options['type'] = 'datetime';
|
||||
$options['dateFormat'] = $dformat;
|
||||
$options['timeFormat'] = $tformat;
|
||||
$options = array(
|
||||
'type' => 'datetime',
|
||||
'dateformat' => $dFormat,
|
||||
'timeformat' => $tFormat,
|
||||
'firstDay' => 1, // 0 = Sunday.
|
||||
'size' => 12
|
||||
);
|
||||
// $options['dateFormat'] = $dformat;
|
||||
// $options['timeFormat'] = $tformat;
|
||||
|
||||
return e107::getForm()->datepicker($calName,$calVal,$options);
|
||||
|
||||
// return $this->_cal->make_input_field($calOptions, $calAttrib);
|
||||
}
|
||||
|
||||
|
||||
@@ -1456,6 +1577,9 @@ class mailoutAdminClass extends e107MailManager
|
||||
case 'trunc200' :
|
||||
$text .= $this->e107->tp->text_truncate($row[$fieldName], 200, '...');
|
||||
break;
|
||||
case 'chars' : // Show generated html as is
|
||||
$text .= htmlspecialchars($row[$fieldName], ENT_COMPAT, 'UTF-8');
|
||||
break;
|
||||
case 'contentstatus' :
|
||||
$text .= $this->statusToText($row[$fieldName]);
|
||||
break;
|
||||
@@ -1668,6 +1792,42 @@ class mailoutAdminClass extends e107MailManager
|
||||
$this->e107->admin_log->log_event('MAIL_05', implode('[!br!]', $results), E_LOG_INFORMATIVE, '');
|
||||
return $noError;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all the available email templates, by name and variable name
|
||||
*
|
||||
* @param string $sel - currently (all|system|user) - selects template type
|
||||
*
|
||||
* @return array - key is the variable name of the template, value is the stored template name
|
||||
*/
|
||||
public function getEmailTemplateNames($sel = 'all')
|
||||
{
|
||||
$ret = array();
|
||||
foreach (array(e_THEME.'templates/email_template.php', THEME.'templates/email_template.php') as $templateFileName ) // Override file then defaults
|
||||
if (is_readable($templateFileName))
|
||||
{
|
||||
require($templateFileName);
|
||||
$tVars = get_defined_vars();
|
||||
if (isset($tVars['GLOBALS'])) unset($tVars['GLOBALS']);
|
||||
foreach ($tVars as $tKey => $tData)
|
||||
{
|
||||
if (is_array($tData) && isset($tData['template_name']))
|
||||
{
|
||||
if (!isset($tData['template_type']) || ($tData['template_type'] == 'all') || ($tData['template_type'] == $sel))
|
||||
{
|
||||
$ret[$tKey] = $tData['template_name'];
|
||||
}
|
||||
}
|
||||
if ($tKey != 'ret')
|
||||
{
|
||||
unset($tVars[$tKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -2,16 +2,16 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2010 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* Mailout handling - selector for 'core' users
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/mailout_class.php,v $
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $Revision: 11315 $
|
||||
* $Date: 2010-02-10 18:18:01 +0000 (Wed, 10 Feb 2010) $
|
||||
* $Author: secretr $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* @package e107
|
||||
* @subpackage e107_handlers
|
||||
* @version $Id$;
|
||||
* @version $Id: mailout_class.php 11315 2010-02-10 18:18:01Z secretr $;
|
||||
*
|
||||
* @todo last visit date needs XHTML calendar on display, and needs to accept varying input formats
|
||||
*/
|
||||
@@ -278,15 +278,21 @@ class core_mailout
|
||||
|
||||
$var[0]['html'] = $admin->userClassesTotals('email_to', varset($selectVals['email_to'], ''));
|
||||
$var[1]['html'] = $frm->selectbox('user_search_name', $u_array, varset($selectVals['user_search_name'], ''),'',TRUE)." ".LAN_MAILOUT_47." ".$frm->text('user_search_value', varset($selectVals['user_search_value'], ''));
|
||||
$var[2]['html'] = $admin->comparisonSelect('last_visit_match', varset($selectVals['last_visit_match'], ''))." ".$frm->text('last_visit_date', varset($selectVals['last_visit_date'], 0)); // FIXME: Should include date selector
|
||||
$var[3]['html'] = $admin->ret_extended_field_list('extended_1_name', varset($selectVals['extended_1_name'], ''), TRUE).LAN_MAILOUT_48." ".$frm->text('extended_1_value',varset($selectVals['extended_1_value'], ''));
|
||||
$var[4]['html'] = $admin->ret_extended_field_list('extended_2_name', varset($selectVals['extended_2_name'], ''), TRUE).LAN_MAILOUT_48." ".$frm->text('extended_2_value',varset($selectVals['extended_2_value'],''));
|
||||
|
||||
//$var[2]['html'] = $admin->comparisonSelect('last_visit_match', varset($selectVals['last_visit_match'], ''))." ".$frm->text('last_visit_date', varset($selectVals['last_visit_date'], 0));
|
||||
$var[2]['html'] = $admin->comparisonSelect('last_visit_match', varset($selectVals['last_visit_match'], ''))." ".$admin->makeCalendar('last_visit_date', varset($selectVals['last_visit_date'], 0));
|
||||
$var[1]['caption'] = LAN_MAILOUT_46; // User Search Field.
|
||||
$var[2]['caption'] = LAN_MAILOUT_56; // User last visit
|
||||
|
||||
$extFields = $admin->ret_extended_field_list('extended_1_name', varset($selectVals['extended_1_name'], ''), TRUE);
|
||||
if ($extFields !== FALSE) // Only display next bit if UEFs defined
|
||||
{
|
||||
$var[3]['html'] = $extFields.LAN_MAILOUT_48." ".$frm->text('extended_1_value',varset($selectVals['extended_1_value'], ''));
|
||||
$var[4]['html'] = $admin->ret_extended_field_list('extended_2_name', varset($selectVals['extended_2_name'], ''), TRUE).LAN_MAILOUT_48." ".$frm->text('extended_2_value',varset($selectVals['extended_2_value'],''));
|
||||
|
||||
$var[3]['caption'] = LAN_MAILOUT_46; // Extended user field
|
||||
$var[4]['caption'] = LAN_MAILOUT_46; // Extended user field
|
||||
}
|
||||
}
|
||||
else // Display existing values
|
||||
{
|
||||
if (!vartrue($selectVals['email_to']))
|
||||
@@ -320,6 +326,9 @@ class core_mailout
|
||||
$var[2]['html'] = $selectVals['last_visit_match'].' '.gmstrftime("%D-%M-%Y",$selectVals['last_visit_date']); //FIXME use e107 date function.
|
||||
$var[2]['caption'] = LAN_MAILOUT_56; // User last visit
|
||||
}
|
||||
$extFields = $admin->ret_extended_field_list('extended_1_name', varset($selectVals['extended_1_name'], ''), TRUE);
|
||||
if ($extFields !== FALSE)
|
||||
{
|
||||
if (vartrue($selectVals['extended_1_name']) && vartrue($selectVals['extended_1_value']))
|
||||
{
|
||||
$var[3]['html'] = $selectVals['extended_1_name'].' '.$selectVals['extended_1_value'];
|
||||
@@ -330,11 +339,11 @@ class core_mailout
|
||||
$var[4]['html'] = $selectVals['extended_2_name'].' '.$selectVals['extended_2_value'];
|
||||
$var[4]['caption'] = LAN_MAILOUT_46; // Extended user field
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $var;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
@@ -33,7 +33,7 @@ class notify
|
||||
{
|
||||
global $e_event;
|
||||
|
||||
$this->notify_prefs = e107::getConfig("notify")->getPref();
|
||||
$this->notify_prefs = e107::getConfig('notify')->getPref();
|
||||
|
||||
if(varset($this->notify_prefs['event']))
|
||||
{
|
||||
@@ -54,8 +54,7 @@ class notify
|
||||
/**
|
||||
* Send an email notification following an event.
|
||||
*
|
||||
* For up to a (hard-coded) number of recipients, the mail is sent immediately.
|
||||
* Otherwise its added to the queue
|
||||
* The email is sent via a common interface, which will send immediately for small numbers of recipients, and queue for larger.
|
||||
*
|
||||
* @param string $id - identifies event actions
|
||||
* @param string $subject - subject for email
|
||||
@@ -78,7 +77,18 @@ class notify
|
||||
$emailFilter = $this->notify_prefs['event'][$id]['email'];
|
||||
}
|
||||
$blockOriginator = FALSE; // TODO: set this using a pref
|
||||
if (is_numeric($this -> notify_prefs['event'][$id]['class']))
|
||||
$recipients = array();
|
||||
|
||||
if ($notifyTarget == 'email')
|
||||
{ // Single email address - that can always go immediately
|
||||
if (!$blockOriginator || ($this->notify_prefs['event'][$id]['email'] != USEREMAIL))
|
||||
{
|
||||
$recipients[] = array(
|
||||
'mail_recipient_email' => $this->notify_prefs['event'][$id]['email']
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif (is_numeric($this->notify_prefs['event'][$id]['class']))
|
||||
{
|
||||
switch ($notifyTarget)
|
||||
{
|
||||
@@ -102,82 +112,41 @@ class notify
|
||||
}
|
||||
if (FALSE !== ($count = $e107->sql->db_Select_gen($qry)))
|
||||
{
|
||||
if ($count <= 5)
|
||||
{ // Arbitrary number below which we send emails immediately
|
||||
e107_require_once(e_HANDLER.'mail.php');
|
||||
while ($email = $e107->sql->db_Fetch())
|
||||
{
|
||||
if ($email['user_email'] != $emailFilter)
|
||||
{
|
||||
sendemail($email['user_email'], $subject, $message, $email['user_name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Otherwise add to mailout queue
|
||||
require_once(e_HANDLER.'mail_manager_class.php');
|
||||
$mailer = new e107MailManager;
|
||||
|
||||
|
||||
// Start by creating the mail body
|
||||
$mailData = array(
|
||||
'mail_content_status' => MAIL_STATUS_TEMP,
|
||||
'mail_create_app' => 'notify',
|
||||
'mail_title' => 'NOTIFY',
|
||||
'mail_subject' => $subject,
|
||||
'mail_sender_email' => $pref['siteadminemail'],
|
||||
'mail_sender_name' => $pref['siteadmin'],
|
||||
'mail_send_style' => 'textonly',
|
||||
'mail_notify_complete' => 0, // NEVER notify when this email sent!!!!!
|
||||
'mail_body' => $message
|
||||
);
|
||||
$result = $mailer->saveEmail($mailData, TRUE);
|
||||
if (is_numeric($result))
|
||||
{
|
||||
$mailMainID = $mailData['mail_source_id'] = $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Handle error
|
||||
return; // Probably nothing else we can do
|
||||
}
|
||||
$mailer->mailInitCounters($mailMainID); // Initialise counters for emails added
|
||||
|
||||
// Now add email addresses to the list
|
||||
while ($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
if ($row['user_email'] != $emailFilter)
|
||||
{
|
||||
$uTarget = array('mail_recipient_id' => $row['user_id'],
|
||||
$recipients[] = array('mail_recipient_id' => $row['user_id'],
|
||||
'mail_recipient_name' => $row['user_name'], // Should this use realname?
|
||||
'mail_recipient_email' => $row['user_email']
|
||||
);
|
||||
$result = $mailer->mailAddNoDup($mailMainID, $uTarget, MAIL_STATUS_TEMP);
|
||||
}
|
||||
}
|
||||
$mailer->mailUpdateCounters($mailMainID); // Update the counters
|
||||
$counters = $mailer->mailRetrieveCounters($mailMainID); // Retrieve the counters
|
||||
if ($counters['add'] == 0)
|
||||
}
|
||||
}
|
||||
|
||||
if (count($recipients))
|
||||
{
|
||||
$mailer->deleteEmail($mailMainID); // Probably a fault, but precautionary - delete email
|
||||
}
|
||||
else
|
||||
{
|
||||
$mailer->activateEmail($mailMainID, FALSE); // Actually mark the email for sending
|
||||
}
|
||||
}
|
||||
require_once(e_HANDLER.'mail_manager_class.php');
|
||||
$mailer = new e107MailManager;
|
||||
|
||||
// Create the mail body
|
||||
$mailData = array(
|
||||
'mail_content_status' => MAIL_STATUS_TEMP,
|
||||
'mail_create_app' => 'notify',
|
||||
'mail_title' => 'NOTIFY',
|
||||
'mail_subject' => $subject,
|
||||
'mail_sender_email' => e107::getPref('siteadminemail'),
|
||||
'mail_sender_name' => e107::getPref('siteadmin'),
|
||||
'mail_send_style' => 'textonly',
|
||||
'mail_notify_complete' => 0, // NEVER notify when this email sent!!!!!
|
||||
'mail_body' => $message
|
||||
);
|
||||
$result = $mailer->sendEmails('NOTIFY_TEMPLATE', $mailData, $recipients);
|
||||
$e107->admin_log->e_log_event(10,-1,'NOTIFY',$subject,$message,FALSE,LOG_TO_ROLLING);
|
||||
}
|
||||
}
|
||||
elseif ($notifyTarget == 'email')
|
||||
{ // Single email address - that can always go immediately
|
||||
if (!$blockOriginator || ($this->notify_prefs['event'][$id]['email'] != USEREMAIL))
|
||||
{
|
||||
e107_require_once(e_HANDLER.'mail.php');
|
||||
sendemail($this->notify_prefs['event'][$id]['email'], $subject, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -2,15 +2,15 @@
|
||||
/*~ class.pop3.php
|
||||
.---------------------------------------------------------------------------.
|
||||
| Software: PHPMailer - PHP email class |
|
||||
| Version: 5.0.0 |
|
||||
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
|
||||
| Info: http://phpmailer.sourceforge.net |
|
||||
| Support: http://sourceforge.net/projects/phpmailer/ |
|
||||
| Version: 5.2.2 |
|
||||
| Site: https://code.google.com/a/apache-extras.org/p/phpmailer/ |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| Admin: Andy Prevost (project admininistrator) |
|
||||
| Admin: Jim Jagielski (project admininistrator) |
|
||||
| Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net |
|
||||
| : Marcus Bointon (coolbru) coolbru@users.sourceforge.net |
|
||||
| : Jim Jagielski (jimjag) jimjag@gmail.com |
|
||||
| Founder: Brent R. Matzelle (original founder) |
|
||||
| Copyright (c) 2010-2012, Jim Jagielski. All Rights Reserved. |
|
||||
| Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. |
|
||||
| Copyright (c) 2001-2003, Brent R. Matzelle |
|
||||
| ------------------------------------------------------------------------- |
|
||||
@@ -19,11 +19,6 @@
|
||||
| This program is distributed in the hope that it will be useful - WITHOUT |
|
||||
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
||||
| FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| We offer a number of paid services (www.codeworxtech.com): |
|
||||
| - Web Hosting on highly optimized fast and secure servers |
|
||||
| - Technology Consulting |
|
||||
| - Oursourcing (highly qualified programmers and graphic designers) |
|
||||
'---------------------------------------------------------------------------'
|
||||
*/
|
||||
|
||||
@@ -33,21 +28,21 @@
|
||||
* @package PHPMailer
|
||||
* @author Andy Prevost
|
||||
* @author Marcus Bointon
|
||||
* @author Jim Jagielski
|
||||
* @copyright 2010 - 2012 Jim Jagielski
|
||||
* @copyright 2004 - 2009 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL)
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* POP Before SMTP Authentication Class
|
||||
* Version 5.0.0
|
||||
* PHP POP-Before-SMTP Authentication Class
|
||||
*
|
||||
* Author: Richard Davey (rich@corephp.co.uk)
|
||||
* Modifications: Andy Prevost
|
||||
* License: LGPL, see PHPMailer License
|
||||
* Version 5.2.2
|
||||
*
|
||||
* @license: LGPL, see PHPMailer License
|
||||
*
|
||||
* Specifically for PHPMailer to allow POP before SMTP authentication.
|
||||
* Does not yet work with APOP - if you have an APOP account, contact Richard Davey
|
||||
* Does not yet work with APOP - if you have an APOP account, contact Jim Jagielski
|
||||
* and we can test changes to this script.
|
||||
*
|
||||
* This class is based on the structure of the SMTP class originally authored by Chris Ryan
|
||||
@@ -56,7 +51,9 @@
|
||||
* required for POP3 connection, authentication and disconnection.
|
||||
*
|
||||
* @package PHPMailer
|
||||
* @author Richard Davey
|
||||
* @author Richard Davey (orig) <rich@corephp.co.uk>
|
||||
* @author Andy Prevost
|
||||
* @author Jim Jagielski
|
||||
*/
|
||||
|
||||
class POP3 {
|
||||
@@ -114,12 +111,27 @@ class POP3 {
|
||||
*/
|
||||
public $password;
|
||||
|
||||
/**
|
||||
* Sets the POP3 PHPMailer Version number
|
||||
* @var string
|
||||
*/
|
||||
public $Version = '5.2.2';
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// PROPERTIES, PRIVATE AND PROTECTED
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @var resource Resource handle for the POP connection socket
|
||||
*/
|
||||
private $pop_conn;
|
||||
/**
|
||||
* @var boolean Are we connected?
|
||||
*/
|
||||
private $connected;
|
||||
/**
|
||||
* @var array Error container
|
||||
*/
|
||||
private $error; // Error log array
|
||||
|
||||
/**
|
||||
@@ -137,10 +149,12 @@ class POP3 {
|
||||
* Combination of public events - connect, login, disconnect
|
||||
* @access public
|
||||
* @param string $host
|
||||
* @param integer $port
|
||||
* @param integer $tval
|
||||
* @param bool|int $port
|
||||
* @param bool|int $tval
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param int $debug_level
|
||||
* @return bool
|
||||
*/
|
||||
public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) {
|
||||
$this->host = $host;
|
||||
@@ -190,7 +204,7 @@ class POP3 {
|
||||
* Connect to the POP3 server
|
||||
* @access public
|
||||
* @param string $host
|
||||
* @param integer $port
|
||||
* @param bool|int $port
|
||||
* @param integer $tval
|
||||
* @return boolean
|
||||
*/
|
||||
@@ -259,7 +273,7 @@ class POP3 {
|
||||
$this->connected = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,12 +314,9 @@ class POP3 {
|
||||
|
||||
if ($this->checkResponse($pop3_response)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,15 +2,15 @@
|
||||
/*~ class.smtp.php
|
||||
.---------------------------------------------------------------------------.
|
||||
| Software: PHPMailer - PHP email class |
|
||||
| Version: 5.0.0 |
|
||||
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
|
||||
| Info: http://phpmailer.sourceforge.net |
|
||||
| Support: http://sourceforge.net/projects/phpmailer/ |
|
||||
| Version: 5.2.2 |
|
||||
| Site: https://code.google.com/a/apache-extras.org/p/phpmailer/ |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| Admin: Andy Prevost (project admininistrator) |
|
||||
| Admin: Jim Jagielski (project admininistrator) |
|
||||
| Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net |
|
||||
| : Marcus Bointon (coolbru) coolbru@users.sourceforge.net |
|
||||
| : Jim Jagielski (jimjag) jimjag@gmail.com |
|
||||
| Founder: Brent R. Matzelle (original founder) |
|
||||
| Copyright (c) 2010-2012, Jim Jagielski. All Rights Reserved. |
|
||||
| Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. |
|
||||
| Copyright (c) 2001-2003, Brent R. Matzelle |
|
||||
| ------------------------------------------------------------------------- |
|
||||
@@ -19,11 +19,6 @@
|
||||
| This program is distributed in the hope that it will be useful - WITHOUT |
|
||||
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
||||
| FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| We offer a number of paid services (www.codeworxtech.com): |
|
||||
| - Web Hosting on highly optimized fast and secure servers |
|
||||
| - Technology Consulting |
|
||||
| - Oursourcing (highly qualified programmers and graphic designers) |
|
||||
'---------------------------------------------------------------------------'
|
||||
*/
|
||||
|
||||
@@ -34,16 +29,18 @@
|
||||
* @author Andy Prevost
|
||||
* @author Marcus Bointon
|
||||
* @copyright 2004 - 2008 Andy Prevost
|
||||
* @author Jim Jagielski
|
||||
* @copyright 2010 - 2012 Jim Jagielski
|
||||
* @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL)
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
|
||||
* commands except TURN which will always return a not implemented
|
||||
* error. SMTP also provides some utility methods for sending mail
|
||||
* to an SMTP server.
|
||||
* original author: Chris Ryan
|
||||
* PHP RFC821 SMTP client
|
||||
*
|
||||
* Implements all the RFC 821 SMTP commands except TURN which will always return a not implemented error.
|
||||
* SMTP also provides some utility methods for sending mail to an SMTP server.
|
||||
* @author Chris Ryan
|
||||
* @package PHPMailer
|
||||
*/
|
||||
|
||||
class SMTP {
|
||||
@@ -54,7 +51,7 @@ class SMTP {
|
||||
public $SMTP_PORT = 25;
|
||||
|
||||
/**
|
||||
* SMTP reply line ending
|
||||
* SMTP reply line ending (don't change)
|
||||
* @var string
|
||||
*/
|
||||
public $CRLF = "\r\n";
|
||||
@@ -65,24 +62,70 @@ class SMTP {
|
||||
*/
|
||||
public $do_debug; // the level of debug to perform
|
||||
|
||||
/**
|
||||
* Sets the function/method to use for debugging output.
|
||||
* Right now we only honor "echo" or "error_log"
|
||||
* @var string
|
||||
*/
|
||||
public $Debugoutput = "echo";
|
||||
|
||||
/**
|
||||
* Sets VERP use on/off (default is off)
|
||||
* @var bool
|
||||
*/
|
||||
public $do_verp = false;
|
||||
|
||||
/**
|
||||
* Sets the SMTP timeout value for reads, in seconds
|
||||
* @var int
|
||||
*/
|
||||
public $Timeout = 15;
|
||||
|
||||
/**
|
||||
* Sets the SMTP timelimit value for reads, in seconds
|
||||
* @var int
|
||||
*/
|
||||
public $Timelimit = 30;
|
||||
|
||||
/**
|
||||
* Sets the SMTP PHPMailer Version number
|
||||
* @var string
|
||||
*/
|
||||
public $Version = '5.2.2';
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// PROPERTIES, PRIVATE AND PROTECTED
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
private $smtp_conn; // the socket to the server
|
||||
private $error; // error if any on the last call
|
||||
private $helo_rply; // the reply the server sent to us for HELO
|
||||
/**
|
||||
* @var resource The socket to the server
|
||||
*/
|
||||
private $smtp_conn;
|
||||
/**
|
||||
* @var string Error message, if any, for the last call
|
||||
*/
|
||||
private $error;
|
||||
/**
|
||||
* @var string The reply the server sent to us for HELO
|
||||
*/
|
||||
private $helo_rply;
|
||||
|
||||
/**
|
||||
* Outputs debugging info via user-defined method
|
||||
* @param string $str
|
||||
*/
|
||||
private function edebug($str) {
|
||||
if ($this->Debugoutput == "error_log") {
|
||||
error_log($str);
|
||||
} else {
|
||||
echo $str;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the class so that the data is in a known state.
|
||||
* @access public
|
||||
* @return void
|
||||
* @return SMTP
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->smtp_conn = 0;
|
||||
@@ -107,6 +150,9 @@ class SMTP {
|
||||
* SMTP CODE SUCCESS: 220
|
||||
* SMTP CODE FAILURE: 421
|
||||
* @access public
|
||||
* @param string $host
|
||||
* @param int $port
|
||||
* @param int $tval
|
||||
* @return bool
|
||||
*/
|
||||
public function Connect($host, $port = 0, $tval = 30) {
|
||||
@@ -136,21 +182,26 @@ class SMTP {
|
||||
"errno" => $errno,
|
||||
"errstr" => $errstr);
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// SMTP server can take longer to respond, give longer timeout for first read
|
||||
// Windows does not have support for this timeout function
|
||||
if(substr(PHP_OS, 0, 3) != "WIN")
|
||||
socket_set_timeout($this->smtp_conn, $tval, 0);
|
||||
if(substr(PHP_OS, 0, 3) != "WIN") {
|
||||
$max = ini_get('max_execution_time');
|
||||
if ($max != 0 && $tval > $max) { // don't bother if unlimited
|
||||
@set_time_limit($tval);
|
||||
}
|
||||
stream_set_timeout($this->smtp_conn, $tval, 0);
|
||||
}
|
||||
|
||||
// get any announcement
|
||||
$announce = $this->get_lines();
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />');
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -179,7 +230,7 @@ class SMTP {
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
|
||||
if($code != 220) {
|
||||
@@ -188,7 +239,7 @@ class SMTP {
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -205,9 +256,54 @@ class SMTP {
|
||||
* Performs SMTP authentication. Must be run after running the
|
||||
* Hello() method. Returns true if successfully authenticated.
|
||||
* @access public
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param string $authtype
|
||||
* @param string $realm
|
||||
* @param string $workstation
|
||||
* @return bool
|
||||
*/
|
||||
public function Authenticate($username, $password) {
|
||||
public function Authenticate($username, $password, $authtype='LOGIN', $realm='', $workstation='') {
|
||||
if (empty($authtype)) {
|
||||
$authtype = 'LOGIN';
|
||||
}
|
||||
|
||||
switch ($authtype) {
|
||||
case 'PLAIN':
|
||||
// Start authentication
|
||||
fputs($this->smtp_conn,"AUTH PLAIN" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($code != 334) {
|
||||
$this->error =
|
||||
array("error" => "AUTH not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Send encoded username and password
|
||||
fputs($this->smtp_conn, base64_encode("\0".$username."\0".$password) . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($code != 235) {
|
||||
$this->error =
|
||||
array("error" => "Authentication not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'LOGIN':
|
||||
// Start authentication
|
||||
fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
|
||||
|
||||
@@ -220,7 +316,7 @@ class SMTP {
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -237,7 +333,7 @@ class SMTP {
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -254,11 +350,70 @@ class SMTP {
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'NTLM':
|
||||
/*
|
||||
* ntlm_sasl_client.php
|
||||
** Bundled with Permission
|
||||
**
|
||||
** How to telnet in windows: http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx
|
||||
** PROTOCOL Documentation http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication
|
||||
*/
|
||||
require_once('ntlm_sasl_client.php');
|
||||
$temp = new stdClass();
|
||||
$ntlm_client = new ntlm_sasl_client_class;
|
||||
if(! $ntlm_client->Initialize($temp)){//let's test if every function its available
|
||||
$this->error = array("error" => $temp->error);
|
||||
if($this->do_debug >= 1) {
|
||||
$this->edebug("You need to enable some modules in your php.ini file: " . $this->error["error"] . $this->CRLF);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$msg1 = $ntlm_client->TypeMsg1($realm, $workstation);//msg1
|
||||
|
||||
fputs($this->smtp_conn,"AUTH NTLM " . base64_encode($msg1) . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
|
||||
if($code != 334) {
|
||||
$this->error =
|
||||
array("error" => "AUTH not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$challange = substr($rply,3);//though 0 based, there is a white space after the 3 digit number....//msg2
|
||||
$challange = base64_decode($challange);
|
||||
$ntlm_res = $ntlm_client->NTLMResponse(substr($challange,24,8),$password);
|
||||
$msg3 = $ntlm_client->TypeMsg3($ntlm_res,$username,$realm,$workstation);//msg3
|
||||
// Send encoded username
|
||||
fputs($this->smtp_conn, base64_encode($msg3) . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($code != 235) {
|
||||
$this->error =
|
||||
array("error" => "Could not authenticate",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -273,7 +428,7 @@ class SMTP {
|
||||
if($sock_status["eof"]) {
|
||||
// the socket is valid but we are not connected
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";
|
||||
$this->edebug("SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected");
|
||||
}
|
||||
$this->Close();
|
||||
return false;
|
||||
@@ -321,6 +476,7 @@ class SMTP {
|
||||
* SMTP CODE FAILURE: 451,554
|
||||
* SMTP CODE ERROR : 500,501,503,421
|
||||
* @access public
|
||||
* @param string $msg_data
|
||||
* @return bool
|
||||
*/
|
||||
public function Data($msg_data) {
|
||||
@@ -338,7 +494,7 @@ class SMTP {
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
|
||||
if($code != 354) {
|
||||
@@ -347,7 +503,7 @@ class SMTP {
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -432,7 +588,7 @@ class SMTP {
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
@@ -441,7 +597,7 @@ class SMTP {
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -458,6 +614,7 @@ class SMTP {
|
||||
* SMTP CODE SUCCESS: 250
|
||||
* SMTP CODE ERROR : 500, 501, 504, 421
|
||||
* @access public
|
||||
* @param string $host
|
||||
* @return bool
|
||||
*/
|
||||
public function Hello($host = '') {
|
||||
@@ -488,6 +645,8 @@ class SMTP {
|
||||
/**
|
||||
* Sends a HELO/EHLO command.
|
||||
* @access private
|
||||
* @param string $hello
|
||||
* @param string $host
|
||||
* @return bool
|
||||
*/
|
||||
private function SendHello($hello, $host) {
|
||||
@@ -497,7 +656,7 @@ class SMTP {
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
@@ -506,7 +665,7 @@ class SMTP {
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -528,6 +687,7 @@ class SMTP {
|
||||
* SMTP CODE SUCCESS: 552,451,452
|
||||
* SMTP CODE SUCCESS: 500,501,421
|
||||
* @access public
|
||||
* @param string $from
|
||||
* @return bool
|
||||
*/
|
||||
public function Mail($from) {
|
||||
@@ -539,14 +699,14 @@ class SMTP {
|
||||
return false;
|
||||
}
|
||||
|
||||
$useVerp = ($this->do_verp ? "XVERP" : "");
|
||||
$useVerp = ($this->do_verp ? " XVERP" : "");
|
||||
fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
@@ -555,7 +715,7 @@ class SMTP {
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -571,6 +731,7 @@ class SMTP {
|
||||
* SMTP CODE SUCCESS: 221
|
||||
* SMTP CODE ERROR : 500
|
||||
* @access public
|
||||
* @param bool $close_on_error
|
||||
* @return bool
|
||||
*/
|
||||
public function Quit($close_on_error = true) {
|
||||
@@ -589,7 +750,7 @@ class SMTP {
|
||||
$byemsg = $this->get_lines();
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />');
|
||||
}
|
||||
|
||||
$rval = true;
|
||||
@@ -603,7 +764,7 @@ class SMTP {
|
||||
"smtp_rply" => substr($byemsg,4));
|
||||
$rval = false;
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -624,6 +785,7 @@ class SMTP {
|
||||
* SMTP CODE FAILURE: 550,551,552,553,450,451,452
|
||||
* SMTP CODE ERROR : 500,501,503,421
|
||||
* @access public
|
||||
* @param string $to
|
||||
* @return bool
|
||||
*/
|
||||
public function Recipient($to) {
|
||||
@@ -641,7 +803,7 @@ class SMTP {
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
|
||||
if($code != 250 && $code != 251) {
|
||||
@@ -650,7 +812,7 @@ class SMTP {
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -684,7 +846,7 @@ class SMTP {
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
@@ -693,7 +855,7 @@ class SMTP {
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -715,6 +877,7 @@ class SMTP {
|
||||
* SMTP CODE SUCCESS: 552,451,452
|
||||
* SMTP CODE SUCCESS: 500,501,502,421
|
||||
* @access public
|
||||
* @param string $from
|
||||
* @return bool
|
||||
*/
|
||||
public function SendAndMail($from) {
|
||||
@@ -732,7 +895,7 @@ class SMTP {
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
@@ -741,7 +904,7 @@ class SMTP {
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -765,7 +928,7 @@ class SMTP {
|
||||
$this->error = array("error" => "This method, TURN, of the SMTP ".
|
||||
"is not implemented");
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -794,21 +957,47 @@ class SMTP {
|
||||
*/
|
||||
private function get_lines() {
|
||||
$data = "";
|
||||
while($str = @fgets($this->smtp_conn,515)) {
|
||||
$endtime = 0;
|
||||
/* If for some reason the fp is bad, don't inf loop */
|
||||
if (!is_resource($this->smtp_conn)) {
|
||||
return $data;
|
||||
}
|
||||
stream_set_timeout($this->smtp_conn, $this->Timeout);
|
||||
if ($this->Timelimit > 0) {
|
||||
$endtime = time() + $this->Timelimit;
|
||||
}
|
||||
while(is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
|
||||
$str = @fgets($this->smtp_conn,515);
|
||||
if($this->do_debug >= 4) {
|
||||
echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />';
|
||||
echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />');
|
||||
$this->edebug("SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />');
|
||||
}
|
||||
$data .= $str;
|
||||
if($this->do_debug >= 4) {
|
||||
echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />';
|
||||
$this->edebug("SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />');
|
||||
}
|
||||
// if 4th character is a space, we are done reading, break the loop
|
||||
if(substr($str,3,1) == " ") { break; }
|
||||
// Timed-out? Log and break
|
||||
$info = stream_get_meta_data($this->smtp_conn);
|
||||
if ($info['timed_out']) {
|
||||
if($this->do_debug >= 4) {
|
||||
$this->edebug("SMTP -> get_lines(): timed-out (" . $this->Timeout . " seconds) <br />");
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Now check if reads took too long
|
||||
if ($endtime) {
|
||||
if (time() > $endtime) {
|
||||
if($this->do_debug >= 4) {
|
||||
$this->edebug("SMTP -> get_lines(): timelimit reached (" . $this->Timelimit . " seconds) <br />");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@@ -47,7 +47,7 @@ $action = $e107->tp->toDB(varset($_GET['mode'],'makemail'));
|
||||
$text .= 'Email addresses may be contributed by plugins (such as newsletter), and duplicates are removed when the mail is sent<br />';
|
||||
$text .= 'Any attachment is selected from the list of valid downloads.<br />';
|
||||
$text .= 'Mail may be sent as plain text (most universal, and least at risk of being classed as spam), or as HTML (in which case a plain text alternative is automatically generated). The theme style
|
||||
may optionally be added to the email';
|
||||
may optionally be added to the email. Alternatively a predefined template can be selected.';
|
||||
break;
|
||||
case 'recipients' :
|
||||
$text = 'Shows all recipients or potential recipients of an email, together with current status';
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
@@ -225,8 +225,8 @@ define('LAN_MAILOUT_203', 'No sender name specified');
|
||||
define('LAN_MAILOUT_204', 'No sender email address specified');
|
||||
define('LAN_MAILOUT_205', 'Email send format error');
|
||||
define('LAN_MAILOUT_206', 'Invalid mail ID (--ID--) specified');
|
||||
define('LAN_MAILOUT_207', '');
|
||||
define('LAN_MAILOUT_208', '');
|
||||
define('LAN_MAILOUT_207', 'Template load error');
|
||||
define('LAN_MAILOUT_208', 'Template conversion error');
|
||||
define('LAN_MAILOUT_209', '');
|
||||
define('LAN_MAILOUT_210', '');
|
||||
|
||||
@@ -245,7 +245,7 @@ define('LAN_MAILOUT_219', 'Partial');
|
||||
define('LAN_MAILOUT_220', 'Email ID --ID-- cancelled');
|
||||
define('LAN_MAILOUT_221', 'Error cancelling email with ID --ID--');
|
||||
define('LAN_MAILOUT_222', 'Default email format');
|
||||
define('LAN_MAILOUT_223', '(Used for some non-bulk emails)');
|
||||
define('LAN_MAILOUT_223', '(Used for some system-generated emails)');
|
||||
define('LAN_MAILOUT_224', 'Inc. Images');
|
||||
define('LAN_MAILOUT_225', 'Include images in email');
|
||||
define('LAN_MAILOUT_226', '--COUNT-- orphaned recipient record(s) removed');
|
||||
@@ -253,7 +253,7 @@ define('LAN_MAILOUT_227', 'Deleted --COUNT-- records from --TABLE--');
|
||||
define('LAN_MAILOUT_228', '--COUNT-- anomalies in mail_content corrected; records: --RECORDS--');
|
||||
define('LAN_MAILOUT_229', 'Email ID --ID-- put on hold');
|
||||
define('LAN_MAILOUT_230', 'Error holding email with ID --ID--');
|
||||
define('LAN_MAILOUT_231', 'Processing method');
|
||||
define('LAN_MAILOUT_231', 'Bounced emails - Processing method');
|
||||
define('LAN_MAILOUT_232', 'None');
|
||||
define('LAN_MAILOUT_233', 'Auto-process script');
|
||||
define('LAN_MAILOUT_234', 'Mail account');
|
||||
@@ -276,7 +276,12 @@ define('LAN_MAILOUT_250', '--- End of notification ---');
|
||||
define('LAN_MAILOUT_251', 'Copy and edit');
|
||||
define('LAN_MAILOUT_252', 'Does various consistency checks on the data, corrects counts, deletes temporary data');
|
||||
define('LAN_MAILOUT_253', 'No recipients found - check for database corruption');
|
||||
define('LAN_MAILOUT_254', '');
|
||||
define('LAN_MAILOUT_254', 'View templated email');
|
||||
define('LAN_MAILOUT_255', 'Templated Email, ID: ');
|
||||
define('LAN_MAILOUT_256', 'Return');
|
||||
define('LAN_MAILOUT_257', 'Generated template');
|
||||
define('LAN_MAILOUT_258', 'Template: ');
|
||||
define('LAN_MAILOUT_259', '');
|
||||
|
||||
|
||||
define('LAN_SEND', 'Send');
|
||||
|
@@ -29,7 +29,7 @@ define("UCSLAN_15", "Create New Class");
|
||||
define("UCSLAN_18", "Clear Class");
|
||||
//define("UCSLAN_19", "Assign users to");
|
||||
define("UCSLAN_20", "class");
|
||||
//define("UCSLAN_21", "User Class Settings");
|
||||
define("UCSLAN_21", "User Class Settings");
|
||||
//define("UCSLAN_22", "Users - click to move ...");
|
||||
//define("UCSLAN_23", "Users in this class ...");
|
||||
define("UCSLAN_24", 'Class Manager');
|
||||
|
@@ -2,31 +2,118 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* Template for signup emails
|
||||
* Templates for all emails
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_themes/templates/email_template.php,v $
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $URL: $
|
||||
* $Revision: 11315 $
|
||||
* $Id: $
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package e107
|
||||
* @subpackage e107_templates
|
||||
* @version $Id: mail_manager_class.php 11315 2010-02-10 18:18:01Z secretr $;
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* This file defines the default templates for each type of email which may be sent.
|
||||
* In general it is assumed that HTML emails are being sent (with a plain text alternate part), although simple plain text emails are also possible.
|
||||
*
|
||||
* Default values are defined for the key elements of an email:
|
||||
*
|
||||
* $EMAIL_HEADER - the first part of the email, usually defining the headers, and everything up to and including <body>
|
||||
* $EMAIL_FOOTER - the last part of the email - it may include a displayed footer, as well as </body> and other 'closing' tags
|
||||
*
|
||||
* Taken as a pair, $EMAIL_HEADER.$EMAIL_FOOTER must generate standards-compliant XHTML
|
||||
*
|
||||
* $EMAIL_BODY - the body text of the email - essentially, the message. It gets sandwiched between $EMAIL_HEADER and $EMAIL_FOOTER
|
||||
* This must generate standards-compliant XHTML in its own right, when taken with an appropriate header and footer section.
|
||||
* Within the template definition, insert the shortcode '{BODY}' to indicate where the passed text of the email is to be stored.
|
||||
*
|
||||
* $EMAIL_OVERRIDES may optionally be defined, in which case it can override default mailout settings (see later). Only define this variable
|
||||
* if you explicitly want overrides - a defined, but empty, variable may have unexpected consequences!
|
||||
*
|
||||
* $EMAIL_PLAINTEXT - an alternative template for the alternative text part of HTML emails. Set to empty string if hard-coded default to be used
|
||||
*
|
||||
*
|
||||
* Templates may be defined for specific purposes
|
||||
* Each template is given a name, which is the name of the variable.
|
||||
* This variable may be a simple string, in which case it defines the email body, and is only available via code.
|
||||
* Alternatively the variable may be an array, in which case each element of the array defines a different aspect of the email:
|
||||
*
|
||||
* $NAME['template_name'] is a user-friendly name shown in the mass mailer
|
||||
* $NAME['template_type'] takes values (user|system|all) to define its purpose - only 'user' and 'all' templates are shown in the mass mailer
|
||||
* $NAME['email_header'] defines the header - optional
|
||||
* $NAME['email_footer'] defines the footer - optional
|
||||
* $NAME['email_body'] defines the body text
|
||||
* $NAME['email_overrides'] defines any mailout settings which are to be overridden (see later) - optional
|
||||
*
|
||||
* The format and functionality of these four main array elements correspond exactly to those of the defaults already described.
|
||||
*
|
||||
* The template need only define those variables which are to be overridden, in which case the default definitions will be used for the others.
|
||||
*
|
||||
*
|
||||
* For templated HTML emails, a style sheet MUST be specified in the header field (if its required), in one of the following forms:
|
||||
*
|
||||
* {STYLESHEET} - embeds the stylesheet for the current site theme
|
||||
* {STYLESHEET=filename,link} - embeds a link to the referenced stylesheet file
|
||||
* {STYLESHEET=filename} - embeds the contents of the specified file
|
||||
* {STYLESHEET=filename,embed} - embeds the contents of the specified file
|
||||
*
|
||||
*
|
||||
* Where no style sheet is specified for an HTML-format email, the following applies:
|
||||
* If 'emailstyle.css' exists in the current theme directory, it is used
|
||||
* otherwise, the theme's 'style.css' is used
|
||||
*
|
||||
* The override variable is an array, which can override any of the following mailer parameters:
|
||||
'mailer', 'smtp_server', 'smtp_username', 'smtp_password', 'sendmail', 'siteadminemail', 'siteadmin', 'smtp_pop3auth',
|
||||
'SMTPDebug', 'subject', 'from', 'fromname', 'replyto', 'send_html', 'add_html_header', 'attachments', 'cc', 'bcc',
|
||||
'bouncepath', 'returnreceipt', 'priority', 'extra_header', 'wordwrap', 'split'
|
||||
|
||||
See e_HANDLER.mail.php for more information
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
global $pref;
|
||||
|
||||
// @TODO: Move signup email into templated form
|
||||
$includeSiteButton = e107::getPref('sitebutton');
|
||||
|
||||
|
||||
$SIGNUPEMAIL_SUBJECT = LAN_SIGNUP_96.' {SITENAME}';
|
||||
$SIGNUPEMAIL_USETHEME = 1; // Use CSS STYLE from THEME: 0 = Off, 1 = external, 2 = embedded
|
||||
$SIGNUPEMAIL_LINKSTYLE = ''; // css to use on links eg. color:red;
|
||||
//$SIGNUPEMAIL_IMAGES = e_IMAGE.$pref['sitebutton']; // comma separated paths to image to embed. referenced below with {IMAGE1} (IMAGE2} etc. Not required
|
||||
//$SIGNUPEMAIL_IMAGES = e_IMAGE.$includeSiteButton; // comma separated paths to image to embed. referenced below with {IMAGE1} (IMAGE2} etc. Not required
|
||||
$SIGNUPEMAIL_CC = ""; // comma separated email addresses to put in CC of the signup email.
|
||||
$SIGNUPEMAIL_BCC = ""; // comma separated email addresses to put in BCC of the signup email.
|
||||
$SIGNUPEMAIL_ATTACHMENTS = ""; // files-path array of attachments. eg. array(e_FILE."myfile.zip",e_FILE."myotherfile.zip");
|
||||
$SIGNUPEMAIL_BACKGROUNDIMAGE = ""; // absolute path to a background image eg. e_IMAGE."mybackground.jpg";
|
||||
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
DEFAULT EMAIL TEMPLATE VALUES
|
||||
=============================================================================*/
|
||||
/**
|
||||
These defaults are used if not overridden by the requirements for a specific template.
|
||||
|
||||
There are five defaults, which must exist, and must be named as follows:
|
||||
$EMAIL_OVERRIDES - array of override settings; e.g. for mail server to use
|
||||
$EMAIL_HEADER - string for the first part of an HTML email
|
||||
$EMAIL_BODY - the 'body' text (usually a default here is meaningless!)
|
||||
$EMAIL_FOOTER - a standard footer - could include a disclaimer, a link to the site
|
||||
$EMAIL_PLAINTEXT - an alternative template for the alternative text part of HTML emails (if empty, alternate text is
|
||||
derived from the HTLM body.
|
||||
|
||||
In most cases only the body will be overridden; in this case it can be overridden using a variable rather than an array.
|
||||
*/
|
||||
/*
|
||||
Optional mailer admin preferences Override. The following mailer parameters can be overridden:
|
||||
'mailer', 'smtp_server', 'smtp_username', 'smtp_password', 'sendmail', 'siteadminemail', 'siteadmin', 'smtp_pop3auth',
|
||||
@@ -34,32 +121,31 @@ Optional mailer admin preferences Override. The following mailer parameters can
|
||||
'bouncepath', 'returnreceipt', 'priority', 'extra_header', 'wordwrap', 'split'
|
||||
|
||||
See e_HANDLER.mail.php for more information
|
||||
|
||||
If required, uncomment the following block and add array elements for options to be overridden - array key is the option name
|
||||
DON'T put in empty fields unless you wish to set the value to an empty value! */
|
||||
/*
|
||||
global $EMAIL_OVERRIDES;
|
||||
$EMAIL_OVERRIDES = array(
|
||||
'bouncepath' => 'some email address',
|
||||
'returnreceipt' => 1
|
||||
);
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default HEADER for all emails
|
||||
*/
|
||||
// Not used in signup email
|
||||
$EMAIL_HEADER = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
|
||||
<html xmlns='http://www.w3.org/1999/xhtml' >
|
||||
<head>
|
||||
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
|
||||
{STYLESHEET}
|
||||
</head>
|
||||
<body>
|
||||
<div style='padding:0px 10px'>
|
||||
<div style='padding:10px'>
|
||||
";
|
||||
|
||||
|
||||
/**
|
||||
* Default FOOTER for all emails
|
||||
*/
|
||||
$EMAIL_BODY = 'Software malfunction - no email body text specified for template'; // Help debug
|
||||
|
||||
// Not used in signup email
|
||||
$EMAIL_FOOTER = "
|
||||
<br /><br />
|
||||
{SITENAME=link}
|
||||
@@ -68,22 +154,43 @@ $EMAIL_FOOTER = "
|
||||
</html>";
|
||||
|
||||
|
||||
/**
|
||||
* Mass-Mailing HEADER (admin->mailout)
|
||||
*/
|
||||
$EMAIL_PLAINTEXT = '';
|
||||
|
||||
/*===========================================================================
|
||||
TEMPLATES FOR SPECIFIC EMAIL TYPES
|
||||
=============================================================================*/
|
||||
|
||||
/**
|
||||
Each template is an array whose name must match that used in the code.
|
||||
The array has two mandatory elements (name and type).
|
||||
The array may have up to five optional elements, each of which overrides the corresponding default value if present
|
||||
An empty element sets the field to empty.
|
||||
An element that is not present results in the default being used.
|
||||
|
||||
Elements are as follows:
|
||||
'template_name' - string - mandatory - a 'user-friendly' name for display
|
||||
'template_type' - string(user|system|all) - mandatory - 'all' and 'user' templates are available for selection in the bulk mailer
|
||||
'email_overrides' - an array
|
||||
'email_header' - string
|
||||
'email_body' - string
|
||||
'email_footer' - string
|
||||
'email_plainText' - string
|
||||
|
||||
// If everything is standard apart from the body, the body can be defined as a simple variable
|
||||
|
||||
*/
|
||||
//TODO - integrate into mailout routine
|
||||
/*
|
||||
$MAILOUT_HEADER = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
|
||||
<html xmlns='http://www.w3.org/1999/xhtml' >
|
||||
<head>
|
||||
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
|
||||
{STYLESHEET}
|
||||
</head>
|
||||
<body>
|
||||
<div style='padding:0px 10px'>
|
||||
<div style='padding:10px'>
|
||||
";
|
||||
|
||||
/**
|
||||
* Mass-Mailing FOOTER (admin->mailout)
|
||||
*/
|
||||
$MAILOUT_FOOTER = "
|
||||
<br /><br />
|
||||
{SITENAME=link}
|
||||
@@ -92,35 +199,16 @@ $MAILOUT_FOOTER = "
|
||||
</html>";
|
||||
|
||||
|
||||
/**
|
||||
* Notification Email HEADER (admin->notify)
|
||||
*/
|
||||
//TODO - integrate into notification routine
|
||||
$NOTIFY_HEADER = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
|
||||
<html xmlns='http://www.w3.org/1999/xhtml' >
|
||||
<head>
|
||||
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
|
||||
</head>
|
||||
<body>
|
||||
<div style='padding:0px 10px'>
|
||||
";
|
||||
|
||||
/**
|
||||
* Notification Email FOOTER (admin->notify)
|
||||
*/
|
||||
$NOTIFY_FOOTER = "
|
||||
<br /><br />
|
||||
{SITENAME=link}
|
||||
</div>
|
||||
</body>
|
||||
</html>";
|
||||
|
||||
|
||||
/*
|
||||
* SIGNUP EMAIL TEMPLATE - BODY.
|
||||
*/
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// 'SIGNUP' TEMPLATE
|
||||
//-------------------------------------------------------------
|
||||
|
||||
$SIGNUPEMAIL_TEMPLATE = "
|
||||
<div style='padding:0px 10px'>
|
||||
<div style='padding:10px'>
|
||||
<div style='text-align:left; width:90%'>
|
||||
".LAN_EMAIL_01." {USERNAME},<br />
|
||||
<br />".
|
||||
@@ -143,21 +231,89 @@ LAN_SIGNUP_97." {SITENAME}<br />
|
||||
<br />
|
||||
{SITENAME}<br />
|
||||
{SITEURL}
|
||||
<br /><br />".($pref['sitebutton'] ? "<a href='".SITEURL."' title=''><img src='".e_IMAGE_ABS.str_replace('{e_IMAGE}', '', $pref['sitebutton'])."' alt='' /></a>" : '')."
|
||||
<br /><br />".($includeSiteButton ? "<a href='".SITEURL."' title=''><img src='".e_IMAGE_ABS.str_replace('{e_IMAGE}', '', $includeSiteButton)."' alt='' /></a>" : '')."
|
||||
</div>
|
||||
</div>
|
||||
";
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// 'NOTIFY' TEMPLATE
|
||||
//-------------------------------------------------------------
|
||||
$NOTIFY_TEMPLATE = array(
|
||||
'template_name' => 'Notify',
|
||||
'template_type' => 'system',
|
||||
'email_overrides' => '',
|
||||
'email_header' => "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
|
||||
<html xmlns='http://www.w3.org/1999/xhtml' >
|
||||
<head>
|
||||
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
|
||||
</head>
|
||||
<body>
|
||||
<div style='padding:0px 10px'>
|
||||
",
|
||||
'email_body' => '{BODY}',
|
||||
'email_footer' => "<br /><br />
|
||||
{SITENAME=link}
|
||||
</div>
|
||||
</body>
|
||||
</html>",
|
||||
'email_plainText' => ''
|
||||
);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// USER-DEFINED TEMPLATES (for mass mailouts)
|
||||
//-------------------------------------------------------------
|
||||
/*
|
||||
* QUICK ADD USER EMAIL TEMPLATE - BODY.
|
||||
* This is the email that is sent when an admin creates a user account in admin. "Quick Add User"
|
||||
USRLAN_185 = A user account has been created for you at {SITEURL} with the following login:<br />Login Name: {LOGIN}<br />Password: {PASSWORD}<br/><br />
|
||||
USRLAN_186 = Please go to the site as soon as possible and log in, then change your password using the \'Settings\' option.<br /><br />
|
||||
You can also change other settings at the same time.<br /><br />Note that your password cannot be recovered if you lose it.
|
||||
*/
|
||||
|
||||
$QUICKADDUSER_TEMPLATE = "<div>".USRLAN_185.USRLAN_186."</div>";
|
||||
|
||||
$TEST_TEMPLATE = array(
|
||||
'template_name' => 'TEst1',
|
||||
'template_type' => 'system',
|
||||
'email_overrides' => '',
|
||||
// 'email_header' - any header information (usually loaded from the default)
|
||||
'email_body' => '{BODY}',
|
||||
'email_footer' => 'footer',
|
||||
'email_plainText' => ''
|
||||
);
|
||||
$TEST2_TEMPLATE = array(
|
||||
'template_name' => 'TEst2',
|
||||
'template_type' => 'all',
|
||||
'email_overrides' => '',
|
||||
// 'email_header' - any header information (usually loaded from the default)
|
||||
'email_body' => '{BODY}',
|
||||
'email_footer' => 'footer'
|
||||
);
|
||||
$TEST3_TEMPLATE = array(
|
||||
'template_name' => 'TEst4',
|
||||
'template_type' => 'user',
|
||||
'email_overrides' => '',
|
||||
// 'email_header' - any header information (usually loaded from the default)
|
||||
'email_body' => '{BODY}',
|
||||
'email_footer' => 'footer'
|
||||
);
|
||||
$TEST4_TEMPLATE = array(
|
||||
'template_name' => 'TEst5',
|
||||
'email_overrides' => '',
|
||||
// 'email_header' - any header information (usually loaded from the default)
|
||||
'email_body' => '{BODY}',
|
||||
'email_footer' => 'footer'
|
||||
);
|
||||
*/
|
||||
$WHATSNEW_TEMPLATE = array(
|
||||
'template_name' => 'WhatsNew',
|
||||
'template_type' => 'user',
|
||||
'email_overrides' => '',
|
||||
// 'email_header' - any header information (usually loaded from the default)
|
||||
'email_body' => 'All the latest news and updates.<br />{BODY}<br />To find out more, simply click on the links!',
|
||||
// 'email_footer' => 'footer'
|
||||
);
|
||||
$MONTHLYUPDATE_TEMPLATE = array(
|
||||
'template_name' => 'MonthlyUpdate',
|
||||
'template_type' => 'user',
|
||||
'email_overrides' => '',
|
||||
// 'email_header' - any header information (usually loaded from the default)
|
||||
'email_body' => 'Just to keep you up to date, here\'s a reminder of what\'s changed in the past month.<br />
|
||||
{BODY}<br />To find out more, simply click on the links!',
|
||||
// 'email_footer' => 'footer'
|
||||
);
|
||||
|
||||
?>
|
Reference in New Issue
Block a user