Version 4.7.23
This commit is contained in:
1 parent
7124a02564
commit
25ddeb65d6
1791 files changed
+76990
-44452
No files matched your search
+60
-18
@@ -10,6 +10,8 @@
|
||||
|
||||
namespace IPS;
|
||||
|
||||
use IPS\Settings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
@@ -92,26 +94,34 @@ abstract class _Email
|
||||
*/
|
||||
public static function classToUse( $type )
|
||||
{
|
||||
if( \defined( '\IPS\EMAIL_DEBUG_PATH' ) AND \IPS\EMAIL_DEBUG_PATH )
|
||||
foreach( static::outgoingHandlers() as $key => $class )
|
||||
{
|
||||
return 'IPS\Email\Outgoing\Debug';
|
||||
}
|
||||
elseif ( \IPS\Settings::i()->sendgrid_api_key and ( \IPS\Settings::i()->mail_method === 'sendgrid' or ( \IPS\Settings::i()->sendgrid_use_for == 2 ) or ( \IPS\Settings::i()->sendgrid_use_for and $type === static::TYPE_BULK ) ) )
|
||||
{
|
||||
return 'IPS\Email\Outgoing\SendGrid';
|
||||
}
|
||||
elseif ( \IPS\Settings::i()->mail_method === 'smtp' )
|
||||
{
|
||||
return 'IPS\Email\Outgoing\Smtp';
|
||||
}
|
||||
elseif ( \IPS\CIC )
|
||||
{
|
||||
return 'IPS\Email\Outgoing\IpsCic';
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'IPS\Email\Outgoing\Php';
|
||||
if( ( Settings::i()->mail_method == $key AND $class::isUsable( $type ) )
|
||||
OR ( $key == 'sendgrid' and $class::isUsable( $type ) ) // SendGrid is a special use case since it can send bulk mail only.
|
||||
OR ( $key == 'debug' and $class::isUsable( \IPS\Email::TYPE_TRANSACTIONAL ) ) )
|
||||
{
|
||||
return $class;
|
||||
}
|
||||
}
|
||||
|
||||
/* Still here?, fallback to default method */
|
||||
return !\IPS\CIC ? 'IPS\Email\Outgoing\Php' : 'IPS\cloud\Email';
|
||||
}
|
||||
|
||||
/**
|
||||
* Available Outgoing Email Handlers, in order of preference
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function outgoingHandlers(): array
|
||||
{
|
||||
return [
|
||||
'debug' => 'IPS\Email\Outgoing\Debug',
|
||||
'postmark' => 'IPS\Email\Outgoing\Postmark',
|
||||
'sendgrid' => 'IPS\Email\Outgoing\SendGrid',
|
||||
'smtp' => 'IPS\Email\Outgoing\Smtp',
|
||||
'php' => 'IPS\Email\Outgoing\Php'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,6 +169,8 @@ abstract class _Email
|
||||
return new \IPS\Email\Outgoing\Debug( \IPS\EMAIL_DEBUG_PATH );
|
||||
case 'IPS\Email\Outgoing\SendGrid':
|
||||
return new \IPS\Email\Outgoing\SendGrid( \IPS\Settings::i()->sendgrid_api_key );
|
||||
case 'IPS\Email\Outgoing\Postmark':
|
||||
return new \IPS\Email\Outgoing\Postmark( \IPS\Settings::i()->postmark_server_api_key );
|
||||
case 'IPS\Email\Outgoing\Smtp':
|
||||
return new \IPS\Email\Outgoing\Smtp( \IPS\Settings::i()->smtp_protocol, \IPS\Settings::i()->smtp_host, \IPS\Settings::i()->smtp_port, \IPS\Settings::i()->smtp_user, \IPS\Settings::i()->smtp_pass );
|
||||
default:
|
||||
@@ -1126,6 +1138,14 @@ abstract class _Email
|
||||
return isset( \IPS\Data\Store::i()->$storeKey );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this email class usable?
|
||||
*
|
||||
* @param string $type Email Type
|
||||
* @return bool
|
||||
*/
|
||||
abstract public static function isUsable( string $type ): bool;
|
||||
|
||||
/* !Utilities */
|
||||
|
||||
@@ -1662,4 +1682,26 @@ abstract class _Email
|
||||
static::$_failedMail[ $key ] = \IPS\Db::i()->select( 'count(mlog_id)', 'core_mail_error_logs', $where )->first();
|
||||
return static::$_failedMail[ $key ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Form fields for email handler
|
||||
* These will automatically toggle on when the email handler is selected to be used
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function form(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse/Save email form settings
|
||||
*
|
||||
* @param array $values settings array
|
||||
* @return array
|
||||
*/
|
||||
public static function processSettings( array $values ): array
|
||||
{
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user