2 namespace TYPO3\CMS\Core\Mail;
50 if (empty($this->mailSettings)) {
56 throw new \TYPO3\CMS\Core\Exception($e->getMessage(), 1291068569);
59 parent::__construct($this->transport);
83 switch ($this->mailSettings[
'transport']) {
86 list($host, $port) = preg_split(
'/:/', $this->mailSettings[
'transport_smtp_server']);
88 throw new \TYPO3\CMS\Core\Exception(
'$TYPO3_CONF_VARS[\'MAIL\'][\'transport_smtp_server\'] needs to be set when transport is set to "smtp"', 1291068606);
90 if ($port === null || $port ===
'') {
93 $useEncryption = $this->mailSettings[
'transport_smtp_encrypt'] ?: null;
95 $this->transport = \Swift_SmtpTransport::newInstance($host, $port, $useEncryption);
97 $username = $this->mailSettings[
'transport_smtp_username'];
98 if ($username !==
'') {
99 $this->transport->setUsername($username);
101 $password = $this->mailSettings[
'transport_smtp_password'];
102 if ($password !==
'') {
103 $this->transport->setPassword($password);
107 $sendmailCommand = $this->mailSettings[
'transport_sendmail_command'];
108 if (empty($sendmailCommand)) {
109 throw new \TYPO3\CMS\Core\Exception(
'$TYPO3_CONF_VARS[\'MAIL\'][\'transport_sendmail_command\'] needs to be set when transport is set to "sendmail"', 1291068620);
112 $this->transport = \Swift_SendmailTransport::newInstance($sendmailCommand);
115 $mboxFile = $this->mailSettings[
'transport_mbox_file'];
116 if ($mboxFile ==
'') {
117 throw new \TYPO3\CMS\Core\Exception(
'$TYPO3_CONF_VARS[\'MAIL\'][\'transport_mbox_file\'] needs to be set when transport is set to "mbox"', 1294586645);
120 $this->transport = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MboxTransport::class, $mboxFile);
124 $this->transport = \Swift_MailTransport::newInstance();
128 $customTransport = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($this->mailSettings[
'transport'], $this->mailSettings);
130 $this->transport = $customTransport;
132 throw new \RuntimeException($this->mailSettings[
'transport'] .
' is not an implementation of \\Swift_Transport,
133 but must implement that interface to be used as a mail transport.', 1323006478);
149 $this->mailSettings = (array)
$GLOBALS[
'TYPO3_CONF_VARS'][
'MAIL'];
180 $this->
getSignalSlotDispatcher()->dispatch(
'TYPO3\\CMS\\Core\\Mail\\Mailer',
'postInitializeMailer', array($this));