From 13b28a28b4bb61499cee9049a626ac5d835b4a31 Mon Sep 17 00:00:00 2001 From: Chandler Blum Date: Wed, 7 Nov 2018 16:12:27 -0500 Subject: [PATCH] Added ability to set an fSMTP connection for all fEmail instances --- fEmail.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/fEmail.php b/fEmail.php index 6e2e2807..6c859ebe 100644 --- a/fEmail.php +++ b/fEmail.php @@ -92,6 +92,29 @@ class fEmail */ static private $popen_sendmail = FALSE; + /** + * The fSMTP connection to use for all instances of fEmail. + * @var fSMTP + */ + static private $connection = NULL; + + /** + * Sets the fSMTP connection all instances of fEmail will use. + * @var fSMTP + */ + static public function setConnection(fSMTP $connection) + { + static::$connection = $connection; + } + + /** + * returns the fSMTP connection or null if it's not set. + * @return null|fSMTP + */ + public function getConnection() + { + return static::$connection; + } /** * Turns a name and email into a `"name" ` string, or just `email` if no name is provided @@ -1337,6 +1360,10 @@ public function send($connection=NULL) { $this->validate(); + if (static::getConnection() && !$connection) { + $connection = static::getConnection(); + } + $message_id = '<' . fCryptography::randomString(10, 'hexadecimal') . '.' . time() . '@' . self::getFQDN() . '>'; // The mail() function on Windows doesn't support names in headers so