Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
+71
-62
@@ -577,7 +577,7 @@ abstract class _Email
|
||||
* @see <a href='http://www.faqs.org/rfcs/rfc2369.html'>RFC 2369 describes the List-Unsubscribe header</a>
|
||||
*/
|
||||
public function send( $to, $cc=array(), $bcc=array() )
|
||||
{
|
||||
{
|
||||
/* Parse the recipients - do this first in order to extract the language key in case we need it */
|
||||
$this->recipients = array();
|
||||
|
||||
@@ -620,34 +620,14 @@ abstract class _Email
|
||||
}
|
||||
|
||||
/* Replace language stack keys with actual content */
|
||||
$this->language->parseOutputForDisplay( $this->emailBody['plain'] );
|
||||
$this->language->parseOutputForDisplay( $this->emailBody['html'] );
|
||||
$this->language->parseEmail( $this->emailBody['plain'] );
|
||||
$this->language->parseEmail( $this->emailBody['html'] );
|
||||
$this->language->parseOutputForDisplay( $this->subject );
|
||||
|
||||
/* Replace attachment and emoticon URLs */
|
||||
\IPS\Output::i()->parseFileObjectUrls( $this->emailBody['html'] );
|
||||
\IPS\Output::i()->parseFileObjectUrls( $this->emailBody['plain'] );
|
||||
|
||||
/* Outlook can't handle protocol-relative URLs, so we need to switch them out */
|
||||
foreach( $this->emailBody as $type => $content )
|
||||
{
|
||||
$this->emailBody[ $type ] = preg_replace_callback( "/\s+?src=(['\"])\/\/([^'\"]+?)(['\"])/ims", function( $matches ){
|
||||
$baseUrl = parse_url( \IPS\Settings::i()->base_url );
|
||||
|
||||
/* Try to preserve http vs https */
|
||||
if( isset( $baseUrl['scheme'] ) )
|
||||
{
|
||||
$url = $baseUrl['scheme'] . '://' . $matches[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = 'http://' . $matches[2];
|
||||
}
|
||||
|
||||
return " src={$matches[1]}{$url}{$matches[1]}";
|
||||
}, $content );
|
||||
}
|
||||
|
||||
$this->parseFileObjectUrls( $this->emailBody['html'] );
|
||||
$this->parseFileObjectUrls( $this->emailBody['plain'] );
|
||||
|
||||
/* Now build the actual email body and send */
|
||||
$boundary = "--==_mimepart_" . md5( uniqid() );
|
||||
|
||||
@@ -694,6 +674,33 @@ abstract class _Email
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse file object URLs and fix protocol relative URLs
|
||||
*
|
||||
* @param string $body Content
|
||||
* @return string
|
||||
*/
|
||||
public function parseFileObjectUrls( &$body )
|
||||
{
|
||||
\IPS\Output::i()->parseFileObjectUrls( $body );
|
||||
|
||||
$body = preg_replace_callback( "/\s+?(srcset|src)=(['\"])\/\/([^'\"]+?)(['\"])/ims", function( $matches ){
|
||||
$baseUrl = parse_url( \IPS\Settings::i()->base_url );
|
||||
|
||||
/* Try to preserve http vs https */
|
||||
if( isset( $baseUrl['scheme'] ) )
|
||||
{
|
||||
$url = $baseUrl['scheme'] . '://' . $matches[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = 'http://' . $matches[3];
|
||||
}
|
||||
|
||||
return " {$matches[1]}={$matches[2]}{$url}{$matches[2]}";
|
||||
}, $body );
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge and Send
|
||||
*
|
||||
@@ -711,6 +718,10 @@ abstract class _Email
|
||||
$vars = array();
|
||||
foreach ( $_vars as $k => $v )
|
||||
{
|
||||
if ( $k === 'unsubscribe_blurb' )
|
||||
{
|
||||
$this->language->parseOutputForDisplay( $v );
|
||||
}
|
||||
$vars[] = array( 'name' => $k, 'content' => $v );
|
||||
}
|
||||
|
||||
@@ -722,10 +733,10 @@ abstract class _Email
|
||||
$body = $this->body['html'];
|
||||
$subject = $this->subject;
|
||||
|
||||
/* Replace attachment and emoticon URLs */
|
||||
\IPS\Output::i()->parseFileObjectUrls( $body );
|
||||
/* Replace attachment and emoticon URLs, fix protocol relative URLs and clean up HTML */
|
||||
$this->parseFileObjectUrls( $body );
|
||||
|
||||
$this->language->parseOutputForDisplay( $body );
|
||||
$this->language->parseEmail( $body );
|
||||
$this->language->parseOutputForDisplay( $subject );
|
||||
|
||||
$response = \IPS\Email::mandrill( 'messages_send', \IPS\Settings::i()->mandrill_api_key, array(
|
||||
@@ -754,12 +765,12 @@ abstract class _Email
|
||||
$subject = $this->subject;
|
||||
|
||||
/* Replace attachment and emoticon URLs */
|
||||
\IPS\Output::i()->parseFileObjectUrls( $content['html'] );
|
||||
\IPS\Output::i()->parseFileObjectUrls( $content['plain'] );
|
||||
$this->parseFileObjectUrls( $content['html'] );
|
||||
$this->parseFileObjectUrls( $content['plain'] );
|
||||
|
||||
/* Replace language stack keys with actual content */
|
||||
$this->language->parseOutputForDisplay( $content['html'] );
|
||||
$this->language->parseOutputForDisplay( $content['plain'] );
|
||||
$this->language->parseEmail( $content['html'] );
|
||||
$this->language->parseEmail( $content['plain'] );
|
||||
$this->language->parseOutputForDisplay( $subject );
|
||||
|
||||
foreach ( $vars as $k => $v )
|
||||
@@ -993,7 +1004,7 @@ abstract class _Email
|
||||
*/
|
||||
public function parseTextForEmail( $text )
|
||||
{
|
||||
\IPS\Output::i()->parseFileObjectUrls( $text );
|
||||
$this->parseFileObjectUrls( $text );
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1038,30 +1049,6 @@ abstract class _Email
|
||||
{
|
||||
$parent = $node->parentNode;
|
||||
|
||||
/* Outlook cannot handle protocol-relative URLs like //site.com/image.jpg - it hangs the client and freezes */
|
||||
if ( $node->tagName == 'img' )
|
||||
{
|
||||
if ( $node->getAttribute('src') )
|
||||
{
|
||||
if ( mb_substr( $node->getAttribute('src'), 0, 2 ) === '//' )
|
||||
{
|
||||
$baseUrl = parse_url( \IPS\Settings::i()->base_url );
|
||||
|
||||
/* Try to preserve http vs https */
|
||||
if( isset( $baseUrl['scheme'] ) )
|
||||
{
|
||||
$url = $baseUrl['scheme'] . ':' . $node->getAttribute('src');
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = 'http:' . $node->getAttribute('src');
|
||||
}
|
||||
|
||||
$node->setAttribute( 'src', $url );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $node->getAttribute('class') )
|
||||
{
|
||||
foreach ( explode( ' ', $node->getAttribute('class') ) as $class )
|
||||
@@ -1074,9 +1061,12 @@ abstract class _Email
|
||||
$cell = $this->_createContainerTable( $parent, $node );
|
||||
$cell->setAttribute( 'style', "font-family: 'Helvetica Neue', helvetica, sans-serif; line-height: 1.5; font-size: 14px; margin: 0;border: 1px solid #e0e0e0;border-left: 3px solid #adadad;position: relative;font-size: 13px;background: #fdfdfd" );
|
||||
|
||||
$citation = $this->_createContainerTable( $cell );
|
||||
$citation->setAttribute( 'style', "font-family: 'Helvetica Neue', helvetica, sans-serif; line-height: 1.5; font-size: 14px; background: #f5f5f5;padding: 8px 15px;color: #000;font-weight: bold;font-size: 13px;display: block;" );
|
||||
$citation->appendChild( new \DOMText( $node->getAttribute('data-cite') ) );
|
||||
if ( $node->getAttribute('data-cite') )
|
||||
{
|
||||
$citation = $this->_createContainerTable( $cell );
|
||||
$citation->setAttribute( 'style', "font-family: 'Helvetica Neue', helvetica, sans-serif; line-height: 1.5; font-size: 14px; background: #f5f5f5;padding: 8px 15px;color: #000;font-weight: bold;font-size: 13px;display: block;" );
|
||||
$citation->appendChild( new \DOMText( $node->getAttribute('data-cite') ) );
|
||||
}
|
||||
|
||||
$containerCell = $this->_createContainerTable( $cell );
|
||||
$containerCell->setAttribute( 'style', "font-family: 'Helvetica Neue', helvetica, sans-serif; line-height: 1.5; font-size: 14px; padding-left:15px" );
|
||||
@@ -1084,7 +1074,12 @@ abstract class _Email
|
||||
while( $node->childNodes->length )
|
||||
{
|
||||
foreach ( $node->childNodes as $child )
|
||||
{
|
||||
{
|
||||
if ( $child instanceof \DOMElement and $child->getAttribute('class') == 'ipsQuote_citation' )
|
||||
{
|
||||
$child->setAttribute( 'style', "font-family: 'Helvetica Neue', helvetica, sans-serif; line-height: 1.5; font-size: 14px; background: #f3f3f3; margin: 0px -15px; padding: 5px 15px; color: #222; font-weight: bold; font-size: 13px; display: block;" );
|
||||
}
|
||||
|
||||
$containerCell->appendChild( $child );
|
||||
}
|
||||
}
|
||||
@@ -1092,6 +1087,7 @@ abstract class _Email
|
||||
$parent->removeChild( $node );
|
||||
break;
|
||||
|
||||
|
||||
/* Make code look good */
|
||||
case 'ipsCode':
|
||||
$cell = $this->_createContainerTable( $parent, $node );
|
||||
@@ -1113,6 +1109,7 @@ abstract class _Email
|
||||
|
||||
/* Remove spoilers */
|
||||
case 'ipsStyle_spoiler':
|
||||
case 'ipsSpoiler':
|
||||
$cell = $this->_createContainerTable( $parent, $node );
|
||||
$cell->setAttribute( 'style', "font-family: 'Helvetica Neue', helvetica, sans-serif; line-height: 1.5; font-size: 14px; margin: 0;padding: 10px;background: #363636;color: #d8d8d8;" );
|
||||
$cell->appendChild( new \DOMText( $this->language->addToStack('email_spoiler_line') ) );
|
||||
@@ -1148,6 +1145,18 @@ abstract class _Email
|
||||
{
|
||||
$url = $url->stripQueryString( 'do' );
|
||||
}
|
||||
|
||||
/* Convert embedDo and embedComment if present */
|
||||
if ( isset( $url->queryString['embedDo'] ) )
|
||||
{
|
||||
$url = $url->setQueryString( 'do', $url->queryString['embedDo'] )->stripQueryString( 'embedDo' );
|
||||
}
|
||||
|
||||
if ( isset( $url->queryString['embedComment'] ) )
|
||||
{
|
||||
$url = $url->setQueryString( 'comment', $url->queryString['embedComment'] )->stripQueryString( 'embedComment' );
|
||||
}
|
||||
|
||||
|
||||
$a = new \DOMElement( 'a' );
|
||||
$parent->insertBefore( $a, $node );
|
||||
|
||||
@@ -93,7 +93,7 @@ class _Incoming
|
||||
/* Get the PEAR email library to parse the email */
|
||||
require_once \IPS\ROOT_PATH . "/system/3rd_party/PEAR/Mail/mimeDecode.php";
|
||||
$decoder = new \Mail_mimeDecode( $email );
|
||||
$this->mail = $decoder->decode( array(
|
||||
$this->mail = @$decoder->decode( array(
|
||||
'include_bodies' => TRUE,
|
||||
'decode_bodies' => TRUE,
|
||||
'decode_headers' => TRUE,
|
||||
@@ -240,10 +240,10 @@ class _Incoming
|
||||
print $this->data['quoted'];
|
||||
|
||||
print '<pre>';
|
||||
$this->data['raw'] = htmlentities($this->data['raw'], \IPS\HTMLENTITIES, 'UTF-8', FALSE);
|
||||
$this->data['rawbody'] = htmlentities($this->data['rawbody'], \IPS\HTMLENTITIES, 'UTF-8', FALSE);
|
||||
$this->data['quoted'] = htmlentities($this->data['quoted'], \IPS\HTMLENTITIES, 'UTF-8', FALSE);
|
||||
$this->data['message'] = htmlentities($this->data['message'], \IPS\HTMLENTITIES, 'UTF-8', FALSE);
|
||||
$this->data['raw'] = htmlspecialchars($this->data['raw'], \IPS\HTMLENTITIES, 'UTF-8', FALSE);
|
||||
$this->data['rawbody'] = htmlspecialchars($this->data['rawbody'], \IPS\HTMLENTITIES, 'UTF-8', FALSE);
|
||||
$this->data['quoted'] = htmlspecialchars($this->data['quoted'], \IPS\HTMLENTITIES, 'UTF-8', FALSE);
|
||||
$this->data['message'] = htmlspecialchars($this->data['message'], \IPS\HTMLENTITIES, 'UTF-8', FALSE);
|
||||
print_r( $this->data );
|
||||
//print_r( $this->mail );
|
||||
print '</pre>';
|
||||
|
||||
@@ -66,15 +66,6 @@ class _SMTP extends \IPS\Email
|
||||
*/
|
||||
public function connect()
|
||||
{
|
||||
$tls = FALSE;
|
||||
|
||||
/* Check for tls:// in the hostname */
|
||||
if ( mb_strpos( \IPS\Settings::i()->smtp_host, 'tls://' ) !== FALSE )
|
||||
{
|
||||
$tls = TRUE;
|
||||
\IPS\Settings::i()->smtp_host = mb_substr( \IPS\Settings::i()->smtp_host, 6 );
|
||||
}
|
||||
|
||||
/* Do we already have a connection? */
|
||||
if( static::$smtp !== NULL )
|
||||
{
|
||||
@@ -82,7 +73,7 @@ class _SMTP extends \IPS\Email
|
||||
}
|
||||
|
||||
/* Connect */
|
||||
static::$smtp = @fsockopen( \IPS\Settings::i()->smtp_host, \IPS\Settings::i()->smtp_port, $errno, $errstr );
|
||||
static::$smtp = @fsockopen( ( ( \IPS\Settings::i()->smtp_protocol == 'ssl' ) ? 'ssl://' : '' ) . \IPS\Settings::i()->smtp_host, \IPS\Settings::i()->smtp_port, $errno, $errstr );
|
||||
|
||||
if ( !static::$smtp )
|
||||
{
|
||||
@@ -100,28 +91,20 @@ class _SMTP extends \IPS\Email
|
||||
throw new \IPS\Email\Outgoing\Exception( \IPS\Member::loggedIn()->language()->addToStack('smtpmail_fsock_error_initial', FALSE, array( 'sprintf' => array( $responseCode ) ) ) );
|
||||
}
|
||||
|
||||
/* If we use ssl:// we need to strip that out */
|
||||
$host = \IPS\Settings::i()->smtp_host;
|
||||
|
||||
if( mb_strpos( \IPS\Settings::i()->smtp_host, '://' ) !== FALSE )
|
||||
{
|
||||
$host = mb_substr( \IPS\Settings::i()->smtp_host, mb_strpos( \IPS\Settings::i()->smtp_host, '://' ) + 3 );
|
||||
}
|
||||
|
||||
/* HELO/EHLO */
|
||||
try
|
||||
{
|
||||
$helo = 'EHLO';
|
||||
$responseCode = $this->_sendCommand( 'EHLO ' . $host, 250 );
|
||||
$responseCode = $this->_sendCommand( 'EHLO ' . \IPS\Settings::i()->smtp_host, 250 );
|
||||
}
|
||||
catch ( \IPS\Email\Outgoing\Exception $e )
|
||||
{
|
||||
$helo = 'HELO';
|
||||
$responseCode = $this->_sendCommand( 'HELO ' . $host, 250 );
|
||||
$responseCode = $this->_sendCommand( 'HELO ' . \IPS\Settings::i()->smtp_host, 250 );
|
||||
}
|
||||
|
||||
/* Is TLS being used? */
|
||||
if( $tls === TRUE )
|
||||
if( \IPS\Settings::i()->smtp_protocol == 'tls' )
|
||||
{
|
||||
$this->_sendCommand( 'STARTTLS', 220 );
|
||||
|
||||
@@ -131,7 +114,7 @@ class _SMTP extends \IPS\Email
|
||||
}
|
||||
|
||||
/* Exchange server (at least) wants EHLO resending for STARTTLS */
|
||||
$this->_sendCommand( $helo . ' ' . $host, 250 );
|
||||
$this->_sendCommand( $helo . ' ' . \IPS\Settings::i()->smtp_host, 250 );
|
||||
}
|
||||
|
||||
/* Authenticate */
|
||||
|
||||
Reference in new issue
Block a user