Swissdude
Swissdude

Reputation: 3556

PHPMailer and anonymous TLS connections

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???

Upvotes: 1

Views: 4463

Answers (2)

Ain
Ain

Reputation: 748

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
    )
);

Upvotes: 0

Synchro
Synchro

Reputation: 37710

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.

Upvotes: 2

Related Questions