Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Debug Email Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 17 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Email\Outgoing;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Exception class for email errors
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 26 Aug 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Email\Outgoing;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief IPS CiC Email Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 13 Dec 2016
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Email\Outgoing;
|
||||
@@ -80,19 +79,26 @@ class _IpsCic extends \IPS\Email
|
||||
*/
|
||||
public function _send( $to, $cc=array(), $bcc=array(), $fromEmail = NULL, $fromName = NULL, $additionalHeaders = array() )
|
||||
{
|
||||
\IPS\Http\Url::external( static::ENDPOINT )->request()->post( array(
|
||||
'siteId' => $this->community,
|
||||
'to' => explode( ',', static::_parseRecipients( $to, TRUE ) ),
|
||||
'cc' => explode( ',', static::_parseRecipients( $cc, TRUE ) ),
|
||||
'bcc' => explode( ',', static::_parseRecipients( $bcc, TRUE ) ),
|
||||
'fromEmail' => $fromEmail ?: \IPS\Settings::i()->email_out,
|
||||
'fromName' => $fromName ?: \IPS\Settings::i()->board_name,
|
||||
'additionalHeaders' => $additionalHeaders,
|
||||
'subject' => $this->compileSubject( static::_getMemberFromRecipients( $to ) ),
|
||||
'html' => $this->compileContent( 'html', static::_getMemberFromRecipients( $to ) ),
|
||||
'plaintext' => $this->compileContent( 'plaintext', static::_getMemberFromRecipients( $to ) ),
|
||||
'precedence' => ( $this->type === static::TYPE_LIST ) ? 'list' : ( $this->type === static::TYPE_BULK ? 'bulk' : '' )
|
||||
) );
|
||||
try
|
||||
{
|
||||
\IPS\Http\Url::external( static::ENDPOINT )->request()->post( array(
|
||||
'siteId' => $this->community,
|
||||
'to' => explode( ',', static::_parseRecipients( $to, TRUE ) ),
|
||||
'cc' => explode( ',', static::_parseRecipients( $cc, TRUE ) ),
|
||||
'bcc' => explode( ',', static::_parseRecipients( $bcc, TRUE ) ),
|
||||
'fromEmail' => $fromEmail ?: \IPS\Settings::i()->email_out,
|
||||
'fromName' => $fromName ?: \IPS\Settings::i()->board_name,
|
||||
'additionalHeaders' => $additionalHeaders,
|
||||
'subject' => $this->compileSubject( static::_getMemberFromRecipients( $to ) ),
|
||||
'html' => $this->compileContent( 'html', static::_getMemberFromRecipients( $to ) ),
|
||||
'plaintext' => $this->compileContent( 'plaintext', static::_getMemberFromRecipients( $to ) ),
|
||||
'precedence' => ( $this->type === static::TYPE_LIST ) ? 'list' : ( $this->type === static::TYPE_BULK ? 'bulk' : '' )
|
||||
) );
|
||||
}
|
||||
catch( \IPS\Http\Request\Exception $e )
|
||||
{
|
||||
throw new \IPS\Email\Outgoing\Exception( $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief PHP Email Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 17 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Email\Outgoing;
|
||||
@@ -51,7 +50,7 @@ class _PHP extends \IPS\Email
|
||||
|
||||
try
|
||||
{
|
||||
if ( !mail( $this->_parseRecipients( $to, TRUE ), static::encodeHeader( $subject ), $this->_compileMessage( static::_getMemberFromRecipients( $to ), $boundary, PHP_EOL ), implode( PHP_EOL, $headers ), \IPS\Settings::i()->php_mail_extra ) )
|
||||
if ( !mail( $this->_parseRecipients( $to, TRUE ), static::encodeHeader( $subject ), $this->_compileMessage( static::_getMemberFromRecipients( $to ), $boundary, PHP_EOL, 68 ), implode( PHP_EOL, $headers ), \IPS\Settings::i()->php_mail_extra ) )
|
||||
{
|
||||
$error = error_get_last();
|
||||
preg_match( "/^(\d+)/", $error['message'], $matches );
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief SendGrid Email Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 17 Oct 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Email\Outgoing;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief SMTP Email Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 17 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Email\Outgoing;
|
||||
@@ -81,9 +80,10 @@ class _SMTP extends \IPS\Email
|
||||
/**
|
||||
* Connect to server
|
||||
*
|
||||
* @param bool $checkSsl If set to FALSE, will skip peer certificate verification for TLS connections
|
||||
* @return void
|
||||
*/
|
||||
public function connect()
|
||||
public function connect( $checkSsl=TRUE )
|
||||
{
|
||||
/* Do we already have a connection? */
|
||||
if( array_key_exists( $this->connectionKey, static::$smtp ) )
|
||||
@@ -127,11 +127,24 @@ class _SMTP extends \IPS\Email
|
||||
/* Is TLS being used? */
|
||||
if( $this->smtpProtocol == 'tls' )
|
||||
{
|
||||
if ( $checkSsl )
|
||||
{
|
||||
@stream_context_set_option( static::$smtp[ $this->connectionKey ], 'ssl', 'verify_peer', false );
|
||||
}
|
||||
|
||||
$this->_sendCommand( 'STARTTLS', 220 );
|
||||
|
||||
if ( !@\stream_socket_enable_crypto( static::$smtp[ $this->connectionKey ], TRUE, version_compare( PHP_VERSION, '5.6.7' ) >= 0 ? STREAM_CRYPTO_METHOD_SSLv23_CLIENT : STREAM_CRYPTO_METHOD_TLS_CLIENT ) )
|
||||
{
|
||||
throw new \IPS\Email\Outgoing\Exception( \IPS\Member::loggedIn()->language()->addToStack('smtpmail_tls_failed') );
|
||||
if ( $checkSsl )
|
||||
{
|
||||
/* Try again, but ignore SSL checks in case the certificate was self-signed, which will fail when initializing TLS. This will be slightly slower to connect, but will avoid an error in most instances. */
|
||||
$this->connect( FALSE );
|
||||
}
|
||||
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') );
|
||||
}
|
||||
}
|
||||
|
||||
/* Exchange server (at least) wants EHLO resending for STARTTLS */
|
||||
@@ -198,7 +211,7 @@ class _SMTP extends \IPS\Email
|
||||
|
||||
foreach ( $toEmails as $toEmail )
|
||||
{
|
||||
$this->_sendCommand( "RCPT TO:<{$toEmail}>", 250 );
|
||||
$this->_sendCommand( "RCPT TO:<{$toEmail}>", 250, TRUE );
|
||||
}
|
||||
|
||||
$this->_sendCommand( 'DATA', 354 );
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief SparkPost Email Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 17 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Email\Outgoing;
|
||||
@@ -28,7 +27,7 @@ class _SparkPost extends \IPS\Email
|
||||
/**
|
||||
* @brief The number of emails that can be sent in one "go"
|
||||
*/
|
||||
const MAX_EMAILS_PER_GO = 2000; // SparkPost "recommends" 2000 per cycle
|
||||
const MAX_EMAILS_PER_GO = 100; // SparkPost "recommends" 2000 per cycle
|
||||
|
||||
/**
|
||||
* @brief If sending a bulk email to more than MAX_EMAILS_PER_GO - does this
|
||||
@@ -123,7 +122,14 @@ class _SparkPost extends \IPS\Email
|
||||
$response = $this->_api( 'transmissions', $request );
|
||||
if ( isset( $response['errors'] ) )
|
||||
{
|
||||
throw new \IPS\Email\Outgoing\Exception( $response['errors'][0]['message'], ( isset( $response['errors'][0]['code'] ) ) ? $response['errors'][0]['code'] : NULL );
|
||||
$error = $response['errors'][0]['message'];
|
||||
|
||||
if( isset( $response['errors'][0]['description'] ) )
|
||||
{
|
||||
$error .= ': ' . $response['errors'][0]['description'];
|
||||
}
|
||||
|
||||
throw new \IPS\Email\Outgoing\Exception( $error, ( isset( $response['errors'][0]['code'] ) ) ? $response['errors'][0]['code'] : NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user