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 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 );
|
||||
|
||||
Reference in new issue
Block a user