/** * Instantiate the object and load the mailer framework */ public function __construct() { $this->strCharset = \Config::get('characterSet'); // Instantiate mailer if (self::$objMailer === null) { if (!\Config::get('useSMTP')) { // Mail $objTransport = \Swift_MailTransport::newInstance(); } else { // SMTP $objTransport = \Swift_SmtpTransport::newInstance(\Config::get('smtpHost'), \Config::get('smtpPort')); // Encryption if (\Config::get('smtpEnc') == 'ssl' || \Config::get('smtpEnc') == 'tls') { $objTransport->setEncryption(\Config::get('smtpEnc')); } // Authentication if (\Config::get('smtpUser') != '') { $objTransport->setUsername(\Config::get('smtpUser'))->setPassword(\Config::get('smtpPass')); } } self::$objMailer = \Swift_Mailer::newInstance($objTransport); } // Instantiate Swift_Message $this->objMessage = \Swift_Message::newInstance(); $this->objMessage->getHeaders()->addTextHeader('X-Mailer', 'Contao Open Source CMS'); }
/** * Instantiate the object and load the mailer framework */ public function __construct() { parent::__construct(); $this->strCharset = $GLOBALS['TL_CONFIG']['characterSet']; // Instantiate mailer if (!is_object(self::$objMailer)) { if (!$GLOBALS['TL_CONFIG']['useSMTP']) { // Mail $objTransport = \Swift_MailTransport::newInstance(); } else { // SMTP $objTransport = \Swift_SmtpTransport::newInstance($GLOBALS['TL_CONFIG']['smtpHost'], $GLOBALS['TL_CONFIG']['smtpPort']); // Encryption if ($GLOBALS['TL_CONFIG']['smtpEnc'] == 'ssl' || $GLOBALS['TL_CONFIG']['smtpEnc'] == 'tls') { $objTransport->setEncryption($GLOBALS['TL_CONFIG']['smtpEnc']); } // Authentication if ($GLOBALS['TL_CONFIG']['smtpUser'] != '') { $objTransport->setUsername($GLOBALS['TL_CONFIG']['smtpUser'])->setPassword($GLOBALS['TL_CONFIG']['smtpPass']); } } self::$objMailer = \Swift_Mailer::newInstance($objTransport); } // Instantiate Swift_Message $this->objMessage = \Swift_Message::newInstance(); $this->objMessage->getHeaders()->addTextHeader('X-Mailer', 'Contao Open Source CMS'); }