1

I'm using phpmailer to establish a TLS connection on port 25. I cannot use a username/password, so it's a anonymous connection.

The server responds with the following:

250-SIZE
                                      250-PIPELINING
                                      250-DSN
                                      250-ENHANCEDSTATUSCODES
                                      250-XXXXXXXA
                                      250-XXXXXXXXXXXXXB
                                      250-AUTH NTLM
                                      250-XXXXXXXXXXXXXXXXXC
                                      250-8BITMIME
                                      250-BINARYMIME
                                      250-XXXXXXXD
                                      250-XXXXXXE
                                      250-XXXXF
                                      250 XXXXXXG

When the STARTTLS-command is sent by phpmailer, the server responds:

CLIENT -> SERVER: STARTTLS
SERVER -> CLIENT: 500 5.3.3 Unrecognized command
SMTP ERROR: STARTTLS command failed: 500 5.3.3 Unrecognized command

So apparently the anonymous TLS isn't offered by the server. Strange thing is, if I connect to the server via telnet, it's working.

Is this a phpmailer-issue? Or just some strange behaviour of the server???

Swissdude
  • 3,486
  • 3
  • 35
  • 68

2 Answers2

2

If it doesn't advertise STARTTLS then it's unlikely to work - are you sure you're connecting to the same server with telnet? It's possible to get an array of the server capabilities that PHPMailer sees by calling this after sending:

var_dump($mail->getSMTPInstance()->getServerExtList());

If you want to test it manually, you should use the openssl s_client command rather than telnet:

openssl s_client -connect mail.example.com:25 -starttls smtp

That will show you more technical details, if it works.

PHPMailer does opportunistic TLS anyway - if it sees that the server advertises STARTTLS, it enables encryption automatically, even if you do not set SMTPSecure = true.

Synchro
  • 35,538
  • 15
  • 81
  • 104
  • Thanks for your answer. The server I'm connecting to via telnet should be the same as the one I'm using via phpmailer. Nevertheless, when I used openssl as suggested by you, I found out that there's a certificate problem. The certificate is issued for a different server than the one I'm connecting to (although it was communicated differently). I'm trying to solve this now and hope it works after that. – Swissdude Mar 29 '16 at 07:19
0

Hope following hack will help you :)

Here is my PHPMailer object

$phpmailer

Comment line

$phpmailer->SMTPSecure = 'tls';

And add

$phpmailer->SMTPOptions = array(
    'ssl' => array(
        'verify_peer'       => false,
        'verify_peer_name'  => false,
        'allow_self_signed' => true
    )
);
Ain
  • 708
  • 1
  • 8
  • 16