Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
+67
-24
@@ -81,10 +81,6 @@ abstract class _Email
|
||||
{
|
||||
return 'IPS\Email\Outgoing\SendGrid';
|
||||
}
|
||||
elseif ( \IPS\Settings::i()->sparkpost_api_key and ( \IPS\Settings::i()->mail_method === 'sparkpost' or ( \IPS\Settings::i()->sparkpost_use_for == 2 ) or ( \IPS\Settings::i()->sparkpost_use_for and $type === static::TYPE_BULK ) ) )
|
||||
{
|
||||
return 'IPS\Email\Outgoing\SparkPost';
|
||||
}
|
||||
elseif ( \IPS\Settings::i()->mail_method === 'smtp' )
|
||||
{
|
||||
return 'IPS\Email\Outgoing\Smtp';
|
||||
@@ -114,8 +110,6 @@ 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\SparkPost':
|
||||
return new \IPS\Email\Outgoing\SparkPost( \IPS\Settings::i()->sparkpost_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:
|
||||
@@ -281,9 +275,16 @@ abstract class _Email
|
||||
{
|
||||
$unsubscribe = static::template( $this->unsubscribeApp, $this->unsubscribeKey, $type, array_merge( $this->unsubscribeParams, array( $member, $this ) ) );
|
||||
}
|
||||
|
||||
|
||||
/* Get our picks */
|
||||
$ourPicks = NULL;
|
||||
if( \IPS\Settings::i()->our_picks_in_email and $this->type !== 'transactional' )
|
||||
{
|
||||
$ourPicks = \IPS\core\Promote::internalStream( 4 );
|
||||
}
|
||||
|
||||
/* Wrap */
|
||||
$return = static::template( 'core', 'emailWrapper', $type, array( $this->subject, $member ?: new \IPS\Member, $return, $unsubscribe, $member === FALSE, '', $this ) );
|
||||
$return = static::template( 'core', 'emailWrapper', $type, array( $this->subject, $member ?: new \IPS\Member, $return, $unsubscribe, $member === FALSE, '', $this, $ourPicks ) );
|
||||
}
|
||||
|
||||
/* Parse language */
|
||||
@@ -351,7 +352,7 @@ abstract class _Email
|
||||
*/
|
||||
public function compileFullEmail( $to, $cc=array(), $bcc=array(), $fromEmail = NULL, $fromName = NULL, $additionalHeaders = array(), $eol = "\r\n", $lineLimit = 998 )
|
||||
{
|
||||
$boundary = "--==_mimepart_" . md5( uniqid() );
|
||||
$boundary = "--==_mimepart_" . md5( mt_rand() );
|
||||
|
||||
$return = '';
|
||||
|
||||
@@ -396,13 +397,17 @@ abstract class _Email
|
||||
/* Basic headers */
|
||||
$headers = array(
|
||||
'MIME-Version' => '1.0',
|
||||
'Auto-Submitted' => 'auto-generated', // This is to try to prevent auto-responders and delivery failure notifications from responding
|
||||
'To' => static::_parseRecipients( $to, TRUE ),
|
||||
'From' => static::encodeHeader( $fromName, $fromEmail ),
|
||||
'Subject' => static::encodeHeader( $subject ),
|
||||
'Date' => date('r'),
|
||||
);
|
||||
|
||||
if ( $this->autoSubmitted )
|
||||
{
|
||||
$headers['Auto-Submitted'] = 'auto-generated'; // This is to try to prevent auto-responders and delivery failure notifications from responding]
|
||||
}
|
||||
|
||||
/* CC/BCC */
|
||||
if ( $cc )
|
||||
{
|
||||
@@ -479,6 +484,11 @@ abstract class _Email
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Auto generated flag
|
||||
*/
|
||||
protected $autoSubmitted = TRUE;
|
||||
|
||||
/**
|
||||
* Send the email
|
||||
*
|
||||
@@ -488,9 +498,10 @@ abstract class _Email
|
||||
* @param mixed $fromEmail The email address to send from. If NULL, default setting is used. NOTE: This should always be a site-controlled domin. Some services like Sparkpost require the domain to be validated.
|
||||
* @param mixed $fromName The name the email should appear from. If NULL, default setting is used
|
||||
* @param array $additionalHeaders Additional headers to send
|
||||
* @param boolean $autoSubmitted The email was auto-generated (yes for notification, bulk mail, no for contact us form)
|
||||
* @return bool
|
||||
*/
|
||||
public function send( $to, $cc=array(), $bcc=array(), $fromEmail = NULL, $fromName = NULL, $additionalHeaders = array() )
|
||||
public function send( $to, $cc=array(), $bcc=array(), $fromEmail = NULL, $fromName = NULL, $additionalHeaders = array(), $autoSubmitted = TRUE )
|
||||
{
|
||||
/* Check we have recipients */
|
||||
if ( !static::_parseRecipients( $to, TRUE ) )
|
||||
@@ -501,8 +512,10 @@ abstract class _Email
|
||||
/* Send the email */
|
||||
try
|
||||
{
|
||||
$this->autoSubmitted = $autoSubmitted;
|
||||
|
||||
/* Send */
|
||||
$this->_send( $to, $cc, $bcc, $fromEmail, $fromName, $additionalHeaders );
|
||||
$this->_send( $to, $cc, $bcc, $fromEmail, $fromName, $additionalHeaders);
|
||||
|
||||
/* If it was successful, reset the failure count */
|
||||
if ( !isset( \IPS\Data\Store::i()->failedMailCount ) OR \IPS\Data\Store::i()->failedMailCount >= 1 )
|
||||
@@ -521,7 +534,7 @@ abstract class _Email
|
||||
$plaintext = $this->compileContent( 'plaintext', static::_getMemberFromRecipients( $to ) );
|
||||
$fromEmail = $fromEmail ?: \IPS\Settings::i()->email_out;
|
||||
$fromName = $fromName ?: \IPS\Settings::i()->board_name;
|
||||
$boundary = "--==_mimepart_" . md5( uniqid() );
|
||||
$boundary = "--==_mimepart_" . md5( mt_rand() );
|
||||
|
||||
\IPS\Db::i()->insert( 'core_mail_error_logs', array(
|
||||
'mlog_date' => time(),
|
||||
@@ -787,23 +800,28 @@ abstract class _Email
|
||||
else
|
||||
{
|
||||
/* See if we found anything from the store */
|
||||
$key = md5( $app . ';' . $key ) . '_email_html';
|
||||
$htmlTemplate = ( isset( \IPS\Data\Store::i()->$key ) ) ? \IPS\Data\Store::i()->$key : NULL;
|
||||
|
||||
if( $htmlTemplate )
|
||||
$storeKey = md5( $app . ';' . $key ) . '_email_html';
|
||||
if ( isset( \IPS\Data\Store::i()->$storeKey ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$key = md5( $app . ';' . $key ) . '_email_plaintext';
|
||||
$plaintextTemplate = ( isset( \IPS\Data\Store::i()->$key ) ) ? \IPS\Data\Store::i()->$key : NULL;
|
||||
|
||||
if( $plaintextTemplate )
|
||||
else
|
||||
{
|
||||
return TRUE;
|
||||
/* Check Database */
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( 'template_id', 'core_email_templates', array( 'template_app=? and template_name=?', $app, $key ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Nothing, it's OK to return false because there is not a separate row for plaintext */
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
$storeKey = md5( $app . ';' . $key ) . '_email_plaintext';
|
||||
return isset( \IPS\Data\Store::i()->$storeKey );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1063,9 +1081,34 @@ abstract class _Email
|
||||
'ipsSpoiler' => '_parseElementForEmailSpoiler',
|
||||
'ipsEmbeddedVideo' => '_parseElementForEmailEmbed',
|
||||
'ipsImage' => '_parseElementForEmailImage',
|
||||
'ipsAttachLink' => '_parseElementForEmailAttachment',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes HTML acceptable for use in emails: Attachments
|
||||
*
|
||||
* @param \DOMElement $node The element
|
||||
* @param \DOMElement $parent The element's parent node
|
||||
* @param \IPS\Lang $language Language
|
||||
* @return string
|
||||
*/
|
||||
protected static function _parseElementForEmailAttachment( \DOMElement &$node, \DOMNode $parent, \IPS\Lang $language )
|
||||
{
|
||||
if ( $node->getAttribute('href') )
|
||||
{
|
||||
$url = $node->getAttribute('href');
|
||||
$parsed = parse_url( $node->getAttribute('href') );
|
||||
|
||||
if ( !isset( $parsed['scheme'] ) )
|
||||
{
|
||||
$baseUrl = parse_url( \IPS\Settings::i()->base_url );
|
||||
$url = $baseUrl['scheme'] . '://' . str_replace( '//', '', $url );
|
||||
$node->setAttribute( 'href', $url );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes HTML acceptable for use in emails: Quotes
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user