Project

General

Profile

Actions

Bug #24941

closed

encrypted SMTP: connection fails due to wrong datatypes

Added by Julian Hofmann almost 14 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
-
Start date:
2011-02-03
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Due to inconsequent datatypes within swiftmailer (and TYPO3), no encryted SMTP connection is possible.

In t3lib_mail_Mailer line 102 f. an instance of Swift_SmtpTransport is instantiated with BOOLEAN as third parameter, but the constructor expects an INT (according to the method description).
Afterward Swift_SmtpTransport calls Swift_Transport_EsmtpTransport::setEncryption() with this parameter, which expects a string as paramter (to be exact 'tls' or 'ssl'), and sets it as protocol for the connection.

Thus, we get a problem in /typo3_src-4.5.0/typo3/contrib/swiftmailer/classes/Swift/Transport/StreamBuffer.php in line 235 by trying to connect our mailserver via fsockopen(). The host is built as:
$host = $this->params['protocol'] . '://' . $host;
The host looks like "1://example.com".
As we know from above, $this->_params['protocol'] was never set as a valid protocol-string, instead it is still a BOOLEAN or INT or something casted to ...whatever - but _no
protocol.

php_sapi_name: cgi-fcgi
PHP_VERSION : 5.2.6-1+lenny9
(issue imported from #M17465)

Actions #1

Updated by Steffen Gebert almost 14 years ago

Hi Julian,

Sounds valid - however SwiftMailer docs also seem to have some issues ;)

You probably read this code:

class Swift_SmtpTransport extends Swift_Transport_EsmtpTransport
{

  /**
   * Create a new SmtpTransport, optionally with $host, $port and $security.
   * @param string $host
   * @param int $port
   * @param int $security
   */
  public function __construct($host = 'localhost', $port = 25,
    $security = null)

However $security is directly passed to setEncryption() of the parrent class Swift_Transport_EsmtpTransport, which is defined as following:

  /**
   * Set the encryption type (tls or ssl)
   * @param string $encryption
   */
  public function setEncryption($enc)
  {
    $this->_params['protocol'] = $enc;
    return $this;
  }

Thus the PHPdoc seems to be wrong and should be "string" (options tls and ssl).

Should the user be able to choose between TLS and SSL? I think TLS should be deployed everywhere, shouldn't it? Otherwise we probably have to change the checkbox to a string field to choose between tls an ssl.

Actions #2

Updated by Steffen Gebert almost 14 years ago

I've now reportet the bug to the SwiftMailer guys:
http://swiftmailer.lighthouseapp.com/projects/21527-swift-mailer/tickets/177-wrong-phpdoc-comment-for-swift_smtptransport__construct

So.. do we need a choise for tls/ssl or is just unencrypted or tls instead fine?

Actions #3

Updated by Julian Hofmann almost 14 years ago

In my opinion it suffices to have one properly working encryption. So there is no need to have a choice.

Actions #4

Updated by Jigal van Hemert almost 14 years ago

It gets stranger:
in Swift_Transport_EsmtpTransport the member $_params is declared as:
private $_params = array(
'protocol' => 'tcp',
'host' => 'localhost',
'port' => 25,
'timeout' => 30,
'blocking' => 1,
'type' => Swift_Transport_IoBuffer::TYPE_SOCKET
);
So the protocol is initialized as 'tcp'.

It feels as if we need to provide either NULL (default value in constructor) or one of the protocols 'tls' / 'ssl' as $security. But NULL would also remove the 'tcp' protocol...

Actions #6

Updated by Steffen Gebert over 13 years ago

Merged:
master: da2373d0199c7cd4ea85f633043856a55408f784
4-5: 443dec1fe0d97b67b1af69247a579e4074277a0b

Actions #7

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF