My System:
- Operating System: Linux VServer
- Webserver: apache2 Mailserver (Using IMAP): Dovecot
- MTA (MailTransportAgent): Postfix + postfix.admin(webapp) to administrate
- my Domain: acegames.de (137.74.140.78)
- TLS-Mail-encryption via port 465 is working
What i want to do:
Execute (Button on website->javascript->ajax->php) php script mail_send.php (+ query) to send mail with swiftmail functions. Swiftmail should use my postfix SMTP-Server to send the mail. The swiftmail files are located in /var/www/html/ts/swiftmailer/.
this is http://ts.acegames.de/mail_send.php or /var/www/html/ts/mail_send.php:
<?php
require_once 'swiftmailer/lib/swift_required.php';
$error = $_GET['err']; $time = $_GET['time']; $user = $_GET['user'];
$transport = Swift_SmtpTransport::newInstance('acegames.de', 465);
$transport->setUsername("[email protected]");
$transport->setPassword("PASS");
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('Teamspeak Error Report');
$message->setFrom(array('[email protected]' => 'USER'));
$message->setTo(array('[email protected]' => 'ts3 report'));
$message->setBody(
'<html>' .
' <head></head>' .
' <body>' .
' <p>Reported Error: ' . $error . '</p>' .
' <p>Time: ' . $time . '</p>' .
' <p>User: ' . $user . '</p>' .
' </body>' .
'</html>', 'text/html' );
// Send the email
$result = $mailer->send($message);
?>
But what i get is a 500-INTERNAL_SERVER_ERROR and the following log: /var/log/apache2/error.log:
[:error] [pid 23732] [client 188.174.41.220:49670] PHP Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection
to acegames.de:465 Timed Out' in
/var/www/html/ts/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:404\nStack
trace:\n#0
/var/www/html/ts/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(289):
Swift_Transport_AbstractSmtpTransport->_getFullResponse(0)\n#1
/var/www/html/ts/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(117):
Swift_Transport_AbstractSmtpTransport->_readGreeting()\n#2
/var/www/html/ts/swiftmailer/lib/classes/Swift/Mailer.php(79):
Swift_Transport_AbstractSmtpTransport->start()\n#3
/var/www/html/ts/mail_send.php(36):
Swift_Mailer->send(Object(Swift_Message))\n#4 {main}\n thrown in
/var/www/html/ts/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php
on line 404, referer: https://ts.acegames.de/
I dont know what the issue is. Ive searched through every logfile (mail.log,syslog,apache2 logs,...) but i havent found anything related to this error.
The error message is saying that it is unable to connect to the mail server you specified. You need to specify TLS like this:
Read more here: Swiftmailer Manual