Version 5.0.0 release

This commit is contained in:
Neo committed 2025-12-19 18:37:58 -08:00
1 parent 90e8c7e903
commit a3a4a9ccbd
651 files changed
+7275 -9481

No files matched your search

+62 -25
View File
@@ -23,6 +23,7 @@ use IPS\core\Feature;
use IPS\Data\Store;
use IPS\Email\Outgoing\Debug;
use IPS\Email\Outgoing\Exception as EmailException;
use IPS\Email\Outgoing\Postmark;
use IPS\Email\Outgoing\SendGrid;
use IPS\Email\Outgoing\Smtp;
use IPS\Http\Url;
@@ -124,35 +125,40 @@ abstract class Email
*/
public static function classToUse( string $type ): string
{
if( defined( '\IPS\EMAIL_DEBUG_PATH' ) AND EMAIL_DEBUG_PATH)
foreach( static::outgoingHandlers() as $key => $class )
{
return 'IPS\Email\Outgoing\Debug';
}
elseif ( Settings::i()->sendgrid_api_key and ( Settings::i()->mail_method === 'sendgrid' or ( Settings::i()->sendgrid_use_for == 2 ) or ( Settings::i()->sendgrid_use_for and $type === static::TYPE_BULK ) ) )
{
return 'IPS\Email\Outgoing\SendGrid';
}
elseif ( Settings::i()->mail_method === 'smtp' )
{
return 'IPS\Email\Outgoing\Smtp';
if( ( Settings::i()->mail_method == $key AND $class::isUsable( $type ) ) OR ( $key == 'debug' and $class::isUsable( Email::TYPE_TRANSACTIONAL ) ) )
{
return $class;
}
}
/* Still here? */
if ( Application::appIsEnabled('cloud') )
{
if ( IN_DEV AND defined( 'DISABLE_CLOUD_EMAIL_LOCALHOST' ) AND \DISABLE_CLOUD_EMAIL_LOCALHOST )
{
return 'IPS\Email\Outgoing\Php';
}
else
{
return static::CLOUD_EMAIL_CLASS;
}
}
else
/* 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
{
$handlers = [
'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'
];
/* Extensions */
foreach ( Application::allExtensions( 'core', 'EmailHandler', FALSE ) as $key => $extension )
{
return 'IPS\Email\Outgoing\Php';
$handlers[ $extension::$handlerKey ] = $extension::class;
}
return $handlers;
}
/**
@@ -165,7 +171,7 @@ abstract class Email
public static function usingCicEmail( ?string $type = null ) : bool
{
$type = $type ?: static::TYPE_TRANSACTIONAL;
return ( static::classToUse( $type ) === static::CLOUD_EMAIL_CLASS );
return ( static::classToUse( $type ) === static::CLOUD_EMAIL_CLASS );
}
/**
@@ -200,11 +206,20 @@ abstract class Email
return match ( $className )
{
'IPS\Email\Outgoing\Debug' => new Debug( EMAIL_DEBUG_PATH ),
'IPS\Email\Outgoing\Postmark'=> new Postmark( Settings::i()->postmark_server_api_key ),
'IPS\Email\Outgoing\SendGrid' => new SendGrid( Settings::i()->sendgrid_api_key ),
'IPS\Email\Outgoing\Smtp' => new Smtp( Settings::i()->smtp_protocol, Settings::i()->smtp_host, Settings::i()->smtp_port, Settings::i()->smtp_user, Settings::i()->smtp_pass ),
default => new $className,
};
}
/**
* Is Outgoing Handler usable?
*
* @param string $type Email type
* @return bool
*/
abstract public static function isUsable( string $type ): bool;
/**
* @brief Type
@@ -1710,4 +1725,26 @@ abstract class Email
static::$_failedMail[ $key ] = 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;
}
}