this is my code:
require_once "Swift/lib/Swift.php";
require_once "Swift/lib/Swift/Connection/SMTP.php";
$log = Swift_LogContainer::getLog();
$log->setLogLevel(Swift_Log::LOG_EVERYTHING);
$log->setMaxSize(200);
try {
$smtp = new Swift_Connection_SMTP("smtp.unibe.ch", 587, Swift_Connection_SMTP::ENC_TLS);
$smtp->setUsername("user");
$smtp->setpassword("pass");
$swift = new Swift($smtp);
$message = new Swift_Message("test", "Test");
$swift->send($message, "rcpt@mail.com", "sender@mail.com");
} catch (Swift_ConnectionException $e) {
echo "There was a problem communicating with SMTP: " . $e->getMessage();
} catch (Swift_Message_MimeException $e) {
echo "There was an unexpected problem building the email:" . $e->getMessage();
}
echo $log->dump(true);
This is the output of the script (with logging):
There was a problem communicating with SMTP: The SMTP connection failed to start [tls://smtp.unibe.ch:587]: fsockopen returned Error Number 0 and Error String ''
Log Information
++ Log level changed to 4
++ Forcing ESMTP mode. HELO is EHLO.
++ Forcing ESMTP mode. HELO is EHLO.
++ Trying to connect...
++ Trying to connect to SMTP server at 'tls://smtp.unibe.ch:587
!! The SMTP connection failed to start [tls://smtp.unibe.ch:587]: fsockopen returned Error Number 0 and Error String ''
++ Log level changed to 4 ++ Forcing ESMTP mode. HELO is EHLO. ++ Forcing ESMTP mode. HELO is EHLO. ++ Trying to connect... ++ Trying to connect to SMTP server at 'tls://smtp.unibe.ch:587 !! The SMTP connection failed to start [tls://smtp.unibe.ch:587]: fsockopen returned Error Number 0 and Error String ''
the port is likely to be correct (can connect to it with telnet)
phpinfo shows that php is compiled with OpenSSL 0.9.8g
furthermore it is possible for me to connect to that server via TLS with the following command from
the shell of the same machine as the script above is running on:
Can somebody give me a hint to what i'm doing wrong?
Thanks in advance,
Gabe
