Version 4.3.6
This commit is contained in:
1 parent
fe1acf984a
commit
1a0c7fd3c2
609 files changed
+14707
-5726
No files matched your search
+15
-6
@@ -278,7 +278,7 @@ abstract class _Email
|
||||
|
||||
/* Get our picks */
|
||||
$ourPicks = NULL;
|
||||
if( \IPS\Settings::i()->our_picks_in_email and $this->type !== 'transactional' )
|
||||
if( \IPS\Settings::i()->promote_community_enabled and \IPS\Settings::i()->our_picks_in_email and $this->type !== 'transactional' )
|
||||
{
|
||||
$ourPicks = \IPS\core\Promote::internalStream( 4 );
|
||||
}
|
||||
@@ -291,7 +291,7 @@ abstract class _Email
|
||||
$language->parseEmail( $return );
|
||||
|
||||
/* Parse URLs */
|
||||
$this->parseFileObjectUrls( $return );
|
||||
static::parseFileObjectUrls( $return );
|
||||
|
||||
/* Return */
|
||||
return $return;
|
||||
@@ -324,7 +324,7 @@ abstract class _Email
|
||||
|
||||
/* Using a template */
|
||||
elseif ( $this->templateApp )
|
||||
{
|
||||
{
|
||||
$return = trim( static::devProcessTemplate( "email__{$this->templateApp}_{$this->templateKey}_subject_" . str_replace( array( ' ', '.', '-', '@' ), '_', $language->short ), $language->get( "mailsub__{$this->templateApp}_{$this->templateKey}" ), array_merge( $this->templateParams, array( $this ) ) ) );
|
||||
}
|
||||
|
||||
@@ -543,7 +543,7 @@ abstract class _Email
|
||||
'mlog_subject' => $subject,
|
||||
'mlog_content' => $html ?: $plaintext,
|
||||
'mlog_resend_data' => json_encode( array( 'type' => $this->type, 'headers' => $this->_compileHeaders( $subject, $to, $cc, $bcc, $fromEmail, $fromName, $additionalHeaders, $boundary ), 'body' => array( 'html' => $html, 'plain' => $plaintext ), 'boundary' => $boundary ) ),
|
||||
'mlog_msg' => $e->getMessage(),
|
||||
'mlog_msg' => json_encode( array( 'message' => $e->getMessage(), 'details' => $e->extraDetails ) ),
|
||||
'mlog_smtp_log' => $this->getLog(),
|
||||
) );
|
||||
|
||||
@@ -597,6 +597,10 @@ abstract class _Email
|
||||
public function mergeAndSend( $recipients, $fromEmail = NULL, $fromName = NULL, $additionalHeaders = array(), \IPS\Lang $language )
|
||||
{
|
||||
$return = 0;
|
||||
|
||||
/* Get the current locale, and then set the language's locale so datetime formatting in templates is correct for this language */
|
||||
$currentLocale = setlocale( LC_ALL, '0' );
|
||||
$language->setLocale();
|
||||
|
||||
foreach ( $recipients as $address => $vars )
|
||||
{
|
||||
@@ -625,6 +629,9 @@ abstract class _Email
|
||||
$return++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now restore the locale we started with */
|
||||
\IPS\Lang::restoreLocale( $currentLocale );
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1211,14 +1218,16 @@ abstract class _Email
|
||||
* Makes HTML acceptable for use in emails: Image
|
||||
*
|
||||
* @param \DOMElement $node The element
|
||||
* @param \DOMElement $parent The element's parent node
|
||||
* @param \DOMNode $parent The element's parent node
|
||||
* @param \IPS\Lang $language Language
|
||||
* @return string
|
||||
*/
|
||||
protected static function _parseElementForEmailImage( \DOMElement &$node, \DOMNode $parent, \IPS\Lang $language )
|
||||
{
|
||||
$maxImageDims = \IPS\Settings::i()->attachment_image_size ? explode( 'x', \IPS\Settings::i()->attachment_image_size ) : array( 1000, 750 );
|
||||
$node->setAttribute( 'style', "max-width:{$maxImageDims[0]}px;max-height:{$maxImageDims[1]}px;" );
|
||||
|
||||
/* Set the max image height and width */
|
||||
$node->setAttribute( 'style', "max-width:{$maxImageDims[0]}px;max-height:{$maxImageDims[1]}px;" . $node->getAttribute('style') ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -290,6 +290,13 @@ class _Email
|
||||
{
|
||||
$this->to = array( $headers['to'] );
|
||||
}
|
||||
/* We need to account for formats like "Doe, John (Contractor)" <a@b.com>, "Doe, Jane" <z@b.com> */
|
||||
elseif( mb_strpos( $headers['to'], '"' ) !== FALSE )
|
||||
{
|
||||
/* The regex here is looking for opening quote, anything except <, comma, anything, closing quote and then stripping the comma so that
|
||||
commas are only used to separate the actual addresses */
|
||||
$this->to = explode( ',', preg_replace( "/\"([^<]*?),(.*?)\"/", "\"$1 $2\"", $headers['to'] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->to = explode( ',', $headers['to'] );
|
||||
@@ -310,6 +317,13 @@ class _Email
|
||||
{
|
||||
$this->cc = $headers['cc'];
|
||||
}
|
||||
/* We need to account for formats like "Doe, John (Contractor)" <a@b.com>, "Doe, Jane" <z@b.com> */
|
||||
elseif( mb_strpos( $headers['cc'], '"' ) !== FALSE )
|
||||
{
|
||||
/* The regex here is looking for opening quote, anything except <, comma, anything, closing quote and then stripping the comma so that
|
||||
commas are only used to separate the actual addresses */
|
||||
$this->cc = explode( ',', preg_replace( "/\"([^<]*?),(.*?)\"/", "\"$1 $2\"", $headers['cc'] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->cc = explode( ",", $headers['cc'] );
|
||||
@@ -540,6 +554,15 @@ class _Email
|
||||
{
|
||||
$exploded = explode( '<br>', $body );
|
||||
}
|
||||
|
||||
/* It is possible the email is formatted with <p></p> and not <br> which can confuse the quote selection */
|
||||
if ( mb_stristr( $body, '</p>' ) or mb_stristr( $body, '</div>' ) )
|
||||
{
|
||||
$body = preg_replace( '#<(p|div)[^>]*?>#', '', $body );
|
||||
$body = preg_replace( '#</(p|div)>#', '<br>', $body );
|
||||
$exploded = explode( '<br>', $body );
|
||||
}
|
||||
|
||||
foreach ( $exploded as $k => $line )
|
||||
{
|
||||
$line = trim( $line );
|
||||
|
||||
@@ -62,7 +62,7 @@ class _Debug extends \IPS\Email
|
||||
{
|
||||
if( !is_dir( $this->debugPath ) )
|
||||
{
|
||||
throw new \IPS\Email\Outgoing\Exception( sprintf( \IPS\Member::loggedIn()->language()->get('no_path_email_debug'), $this->debugPath ) );
|
||||
throw new \IPS\Email\Outgoing\Exception( 'no_path_email_debug', 0, NULL, array( $this->debugPath ) );
|
||||
}
|
||||
|
||||
$fullEmailContents = $this->compileFullEmail( $to, $cc, $bcc, $fromEmail, $fromName, $additionalHeaders );
|
||||
@@ -70,7 +70,7 @@ class _Debug extends \IPS\Email
|
||||
$filename = date("M-j-Y") . '-' . microtime() . '-' . urlencode( mb_substr( $this->_parseRecipients( $to, TRUE ), 0, 200 ) ) . ".eml";
|
||||
if( !@\file_put_contents( rtrim( $this->debugPath, '/' ) . '/' . $filename, $fullEmailContents ) )
|
||||
{
|
||||
throw new \IPS\Email\Outgoing\Exception( \IPS\Member::loggedIn()->language()->addToStack( 'no_write_email_debug', FALSE, array( 'sprintf' => array( rtrim( $this->debugPath, '/' ) . '/' . $filename ) ) ) );
|
||||
throw new \IPS\Email\Outgoing\Exception( 'no_write_email_debug', 0, NULL, array( rtrim( $this->debugPath, '/' ) . '/' . $filename ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,5 +22,25 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _Exception extends \RuntimeException
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Extra details for log
|
||||
*/
|
||||
public $extraDetails = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $message Error message
|
||||
* @param int $code Error Code
|
||||
* @param \Exception|NULL $previous Previous Exception
|
||||
* @param array|NULL $extra Extra details for log
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $message = null, $code = 0, $previous = null, $extra=NULL )
|
||||
{
|
||||
/* Store these for the extraLogData() method */
|
||||
$this->extraDetails = $extra;
|
||||
|
||||
return parent::__construct( $message, $code, $previous );
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class _PHP extends \IPS\Email
|
||||
else
|
||||
{
|
||||
/* If $error is null, mail() is probably disabled */
|
||||
throw new \IPS\Email\Outgoing\Exception( \IPS\Member::loggedIn()->language()->addToStack( 'email_test_mailfunction_disabled', FALSE ) );
|
||||
throw new \IPS\Email\Outgoing\Exception( 'email_test_mailfunction_disabled' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ class _SendGrid extends \IPS\Email
|
||||
'mlog_subject' => $subject,
|
||||
'mlog_content' => $htmlContent,
|
||||
'mlog_resend_data' => NULL,
|
||||
'mlog_msg' => json_encode( $e->getMessage() ),
|
||||
'mlog_msg' => json_encode( array( 'message' => $e->getMessage() ) ),
|
||||
'mlog_smtp_log' => NULL
|
||||
) );
|
||||
|
||||
@@ -210,7 +210,7 @@ class _SendGrid extends \IPS\Email
|
||||
'mlog_subject' => $subject,
|
||||
'mlog_content' => $htmlContent,
|
||||
'mlog_resend_data' => NULL,
|
||||
'mlog_msg' => json_encode( $response['errors'] ),
|
||||
'mlog_msg' => json_encode( array( 'message' => $response['errors'] ) ),
|
||||
'mlog_smtp_log' => NULL
|
||||
) );
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class _SMTP extends \IPS\Email
|
||||
$responseCode = mb_substr( $announce, 0, 3 );
|
||||
if ( $responseCode != 220 )
|
||||
{
|
||||
throw new \IPS\Email\Outgoing\Exception( \IPS\Member::loggedIn()->language()->addToStack('smtpmail_fsock_error_initial', FALSE, array( 'sprintf' => array( $responseCode ) ) ) );
|
||||
throw new \IPS\Email\Outgoing\Exception( 'smtpmail_fsock_error_initial', 0, NULL, array( $responseCode ) );
|
||||
}
|
||||
|
||||
/* HELO/EHLO */
|
||||
@@ -143,7 +143,7 @@ class _SMTP extends \IPS\Email
|
||||
else
|
||||
{
|
||||
/* If it still failed on the second connection attempt, throw the exception */
|
||||
throw new \IPS\Email\Outgoing\Exception( \IPS\Member::loggedIn()->language()->addToStack('smtpmail_tls_failed') );
|
||||
throw new \IPS\Email\Outgoing\Exception( 'smtpmail_tls_failed' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user