Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+26 -51
View File
@@ -10,38 +10,43 @@
namespace IPS\Email\Outgoing;
use IPS\Helpers\Form\Text;
use IPS\Settings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Email;
use IPS\IPS;
use IPS\Settings;
use function defined;
use function function_exists;
use function in_array;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* PHP Email Class
*/
class _PHP extends \IPS\Email
class Php extends Email
{
/**
* Send the email
*
* @param mixed $to The member or email address, or array of members or email addresses, to send to
* @param mixed $cc Addresses to CC (can also be email, member or array of either)
* @param mixed $bcc Addresses to BCC (can also be email, member or array of either)
* @param mixed $fromEmail The email address to send from. If NULL, default setting is used
* @param mixed $fromName The name the email should appear from. If NULL, default setting is used
* @param array $additionalHeaders The name the email should appear from. If NULL, default setting is used
* @param mixed $cc Addresses to CC (can also be email, member or array of either)
* @param mixed $bcc Addresses to BCC (can also be email, member or array of either)
* @param mixed $fromEmail The email address to send from. If NULL, default setting is used
* @param mixed $fromName The name the email should appear from. If NULL, default setting is used
* @param array $additionalHeaders The name the email should appear from. If NULL, default setting is used
* @return void
* @throws \IPS\Email\Outgoing\Exception
* @throws Exception
*/
public function _send( $to, $cc=array(), $bcc=array(), $fromEmail = NULL, $fromName = NULL, $additionalHeaders = array() )
public function _send( mixed $to, mixed $cc=array(), mixed $bcc=array(), mixed $fromEmail = NULL, mixed $fromName = NULL, array $additionalHeaders = array() ) : void
{
if( !\function_exists( 'mail' ) )
if( !function_exists( 'mail' ) )
{
throw new \IPS\Email\Outgoing\Exception( 'email_test_mailfunction_disabled' );
throw new Exception( 'email_test_mailfunction_disabled' );
}
$boundary = "--==_mimepart_" . md5( mt_rand() );
@@ -50,7 +55,7 @@ class _PHP extends \IPS\Email
$headers = array();
foreach( $this->_compileHeaders( $subject, $to, $cc, $bcc, $fromEmail, $fromName, $additionalHeaders, $boundary ) as $k => $v )
{
if ( !\in_array( $k, array( 'To', 'Subject' ) ) )
if ( !in_array( $k, array( 'To', 'Subject' ) ) )
{
$headers[] = "{$k}: {$v}";
}
@@ -60,50 +65,20 @@ class _PHP extends \IPS\Email
{
if ( !mail( $this->_parseRecipients( $to, TRUE ), static::encodeHeader( $subject ), $this->_compileMessage( static::_getMemberFromRecipients( $to ), $boundary, "\r\n", 68 ), implode( "\r\n", $headers ), Settings::i()->php_mail_extra ) )
{
if ( $error = \IPS\IPS::$lastError )
if ( $error = IPS::$lastError )
{
throw new \IPS\Email\Outgoing\Exception( $error->getMessage(), $error->getCode() );
throw new Exception( $error->getMessage(), $error->getCode() );
}
else
{
/* If $error is null, mail() is probably disabled */
throw new \IPS\Email\Outgoing\Exception( 'email_test_mailfunction_disabled' );
throw new Exception( 'email_test_mailfunction_disabled' );
}
}
}
catch ( \Exception $e )
catch ( Exception $e )
{
throw new \IPS\Email\Outgoing\Exception( $e->getMessage() );
throw new Exception( $e->getMessage() );
}
}
/**
* Is this email class usable?
*
* @param string $type Email Type
* @return bool
*/
public static function isUsable( string $type ): bool
{
if( !\IPS\CIC )
{
return true;
}
return false;
}
/**
* 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
{
$form = [];
$form['php_mail_extra'] = new Text( 'php_mail_extra', Settings::i()->php_mail_extra, FALSE, [], NULL, NULL, NULL, 'php_mail_extra' );
return $form;
}
}