Version 4.7.23
This commit is contained in:
1 parent
7124a02564
commit
25ddeb65d6
1791 files changed
+76990
-44452
No files matched your search
@@ -10,6 +10,8 @@
|
||||
|
||||
namespace IPS\Email\Outgoing;
|
||||
|
||||
use IPS\Settings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
@@ -116,6 +118,27 @@ class _SendGrid extends \IPS\Email
|
||||
throw new \IPS\Email\Outgoing\Exception( $response['errors'][0]['message'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this email class usable?
|
||||
*
|
||||
* @param string $type Email Type
|
||||
* @return bool
|
||||
*/
|
||||
public static function isUsable( string $type ): bool
|
||||
{
|
||||
if( ( new \IPS\core\extensions\core\CommunityEnhancements\Sendgrid() )->enabled )
|
||||
{
|
||||
return match( true )
|
||||
{
|
||||
( $type == \IPS\Email::TYPE_TRANSACTIONAL OR $type == \IPS\Email::TYPE_LIST ) AND Settings::i()->sendgrid_use_for == 2 => true,
|
||||
$type == \IPS\Email::TYPE_BULK AND (int) Settings::i()->sendgrid_use_for > 0 => true,
|
||||
default => false
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge and Send
|
||||
@@ -184,7 +207,7 @@ class _SendGrid extends \IPS\Email
|
||||
\IPS\Db::i()->insert( 'core_mail_error_logs', array(
|
||||
'mlog_date' => time(),
|
||||
'mlog_to' => json_encode( $addresses ),
|
||||
'mlog_from' => $fromEmail ?: \IPS\Settings::i()->email_out,
|
||||
'mlog_from' => $fromEmail ?: Settings::i()->email_out,
|
||||
'mlog_subject' => $subject,
|
||||
'mlog_content' => $htmlContent,
|
||||
'mlog_resend_data' => NULL,
|
||||
@@ -202,7 +225,7 @@ class _SendGrid extends \IPS\Email
|
||||
\IPS\Db::i()->insert( 'core_mail_error_logs', array(
|
||||
'mlog_date' => time(),
|
||||
'mlog_to' => json_encode( $addresses ),
|
||||
'mlog_from' => $fromEmail ?: \IPS\Settings::i()->email_out,
|
||||
'mlog_from' => $fromEmail ?: Settings::i()->email_out,
|
||||
'mlog_subject' => $subject,
|
||||
'mlog_content' => $htmlContent,
|
||||
'mlog_resend_data' => NULL,
|
||||
@@ -231,23 +254,23 @@ class _SendGrid extends \IPS\Email
|
||||
$request = array(
|
||||
'personalizations' => array(),
|
||||
'from' => array(
|
||||
'email' => $fromEmail ?: \IPS\Settings::i()->email_out,
|
||||
'name' => $fromName ?: \IPS\Settings::i()->board_name
|
||||
'email' => $fromEmail ?: Settings::i()->email_out,
|
||||
'name' => $fromName ?: Settings::i()->board_name
|
||||
),
|
||||
'tracking_settings' => array(
|
||||
'click_tracking' => array(
|
||||
'enable' => (bool) \IPS\Settings::i()->sendgrid_click_tracking,
|
||||
'enable_text' => (bool) \IPS\Settings::i()->sendgrid_click_tracking,
|
||||
'enable' => (bool) Settings::i()->sendgrid_click_tracking,
|
||||
'enable_text' => (bool) Settings::i()->sendgrid_click_tracking,
|
||||
),
|
||||
'open_tracking' => array(
|
||||
'enable' => (bool) \IPS\Settings::i()->sendgrid_click_tracking,
|
||||
'enable' => (bool) Settings::i()->sendgrid_click_tracking,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ( \IPS\Settings::i()->sendgrid_ip_pool )
|
||||
if ( Settings::i()->sendgrid_ip_pool )
|
||||
{
|
||||
$request['ip_pool_name'] = \IPS\Settings::i()->sendgrid_ip_pool;
|
||||
$request['ip_pool_name'] = Settings::i()->sendgrid_ip_pool;
|
||||
}
|
||||
|
||||
return $request;
|
||||
@@ -362,5 +385,24 @@ class _SendGrid extends \IPS\Email
|
||||
{
|
||||
return $this->_api( 'scopes' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse/Save email form settings
|
||||
*
|
||||
* @param array $values settings array
|
||||
* @return array
|
||||
*/
|
||||
public static function processSettings( array $values ): array
|
||||
{
|
||||
if ( isset( $values['mail_method'] ) and $values['mail_method'] != 'sendgrid' and Settings::i()->sendgrid_use_for == 2 )
|
||||
{
|
||||
$values['sendgrid_use_for'] = 1;
|
||||
}
|
||||
elseif ( isset( $values['mail_method'] ) and $values['mail_method'] == 'sendgrid' )
|
||||
{
|
||||
$values['sendgrid_use_for'] = 2;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user