0

I had to do a migration because the OS was done with security support. I migrated and I've had a lot of trouble sending email.

I've manually setup PHP Pear Mail:

  • Auth_SASL-1.2.0
  • Net_SMTP-1.12.1
  • Net_Socket-1.2.1
  • PEAR-1.10.15

...in order to send clean authenticated emails like on the previous server. So I kept hitting an old error and was told I was running an old version, fine - I got the latest versions of everything until I hit a problem that wasn't a missing file:

fsockopen(): Unable to connect to mail.example.com:465 (Connection refused)

Further investigation in to the file /var/log/exim_mainlog revealed:

2024-07-02 05:13:12 TLS error on connection from [---.---.---.---]:43464 (SSL_accept): timed out

For further PHP debugging information please see the bottom this this post.

So most the solutions for the problems I've encountered are things I end up fixing through WHM. There are firewalls and other security software/plugins/etc. I've read on a Plesk thread that Imunify360 can disable sending emails except for specified Linux users though that option was disabled. I looked through the software listed under plugins. I looked through Exim related pages.

So I'm at a loss as to what is blocking the email from being sent. Worse yet, every test completely locks up the server for 10 minutes short of me forcing a server reboot.

Looking at related questions I ran this command and apparently there are processes sitting on port 465:

[root@server:/root]$ netstat -lnp

tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN 317/exim

tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN 317/exim

tcp6 0 0 :::465 :::* LISTEN 317/exim

I would be very grateful for any insight in to what could be stopping my mail from working please.

   [0] => Array
        (
            [function] => error_handle
            [args] => Array
                (
                    [0] => 2
                    [1] => fsockopen(): Unable to connect to mail.example.com:465 (Connection refused)
                    [2] => /[__SERVER__PATH__]/php/Net/Socket.php
                    [3] => 185
                )
    )

[1] => Array
    (
        [file] => /[__SERVER__PATH__]/php/Net/Socket.php
        [line] => 185
        [function] => fsockopen
        [args] => Array
            (
                [0] => mail.example.com
                [1] => 465
                [2] => 0
                [3] => 
                [4] => 60
            )

    )

[2] => Array
    (
        [file] => /[__SERVER__PATH__]/php/Net/SMTP.php
        [line] => 474
        [function] => connect
        [class] => Net_Socket
        [object] => Net_Socket Object
            (
                [_debug] => 
                [_default_error_mode] => 
                [_default_error_options] => 
                [_default_error_handler] => 
                [_error_class] => PEAR_Error
                [_expected_errors] => Array
                    (
                    )

                [fp] => 
                [blocking] => 1
                [persistent] => 
                [addr] => mail.example.com
                [port] => 465
                [timeout] => 
                [lineLength] => 2048
                [newline] => 

            )

        [type] => ->
        [args] => Array
            (
                [0] => mail.example.com
                [1] => 465
                [2] => 
                [3] => 60
                [4] => Array
                    (
                    )

            )

    )

[3] => Array
    (
        [file] => /[__SERVER__PATH__]/php/Mail/smtp.php
        [line] => 449
        [function] => connect
        [class] => Net_SMTP
        [object] => Net_SMTP Object
            (
                [host] => mail.example.com
                [port] => 465
                [localhost] => localhost
                [auth_methods] => Array
                    (
                        [SCRAM-SHA-512] => Array
                            (
                                [0] => Net_SMTP Object

RECURSION [1] => authScramSHA512 )

                        [SCRAM-SHA-384] => Array
                            (
                                [0] => Net_SMTP Object

RECURSION [1] => authScramSHA384 )

                        [SCRAM-SHA-256] => Array
                            (
                                [0] => Net_SMTP Object

RECURSION [1] => authScramSHA256 )

                        [SCRAM-SHA-224] => Array
                            (
                                [0] => Net_SMTP Object

RECURSION [1] => authScramSHA224 )

                        [SCRAM-SHA-1] => Array
                            (
                                [0] => Net_SMTP Object

RECURSION [1] => authScramSHA1 )

                        [DIGEST-MD5] => Array
                            (
                                [0] => Net_SMTP Object

RECURSION [1] => authDigestMD5 )

                        [CRAM-MD5] => Array
                            (
                                [0] => Net_SMTP Object

RECURSION [1] => authCramMD5 )

                        [LOGIN] => Array
                            (
                                [0] => Net_SMTP Object

RECURSION [1] => authLogin )

                        [PLAIN] => Array
                            (
                                [0] => Net_SMTP Object

RECURSION [1] => authPlain )

                        [XOAUTH2] => Array
                            (
                                [0] => Net_SMTP Object

RECURSION [1] => authXOAuth2 )

                        [OAUTHBEARER] => Array
                            (
                                [0] => Net_SMTP Object

RECURSION [1] => authOAuthBearer )

                    )

                [pipelining] => 
                [pipelined_commands:protected] => 0
                [debug:protected] => 
                [debug_handler:protected] => 
                [socket:protected] => Net_Socket Object
                    (
                        [_debug] => 
                        [_default_error_mode] => 
                        [_default_error_options] => 
                        [_default_error_handler] => 
                        [_error_class] => PEAR_Error
                        [_expected_errors] => Array
                            (
                            )

                        [fp] => 
                        [blocking] => 1
                        [persistent] => 
                        [addr] => mail.example.com
                        [port] => 465
                        [timeout] => 
                        [lineLength] => 2048
                        [newline] => 

                    )

                [socket_options:protected] => Array
                    (
                    )

                [timeout:protected] => 0
                [code:protected] => -1
                [arguments:protected] => Array
                    (
                    )

                [greeting:protected] => 
                [esmtp:protected] => Array
                    (
                    )

                [gssapi_principal:protected] => 
                [gssapi_cname:protected] => 
                [scram_sha_hash_algorithm:protected] => 
            )

        [type] => ->
        [args] => Array
            (
                [0] => 
            )

    )

[4] => Array
    (
        [file] => /[__SERVER__PATH__]/php/Mail/smtp.php
        [line] => 332
        [function] => getSMTPObject
        [class] => Mail_smtp
        [object] => Mail_smtp Object
            (
                [sep] => 

                [_smtp] => Net_SMTP Object
                    (
                        [host] => mail.example.com
                        [port] => 465
                        [localhost] => localhost
                        [auth_methods] => Array
                            (
                                [SCRAM-SHA-512] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authScramSHA512 )

                                [SCRAM-SHA-384] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authScramSHA384 )

                                [SCRAM-SHA-256] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authScramSHA256 )

                                [SCRAM-SHA-224] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authScramSHA224 )

                                [SCRAM-SHA-1] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authScramSHA1 )

                                [DIGEST-MD5] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authDigestMD5 )

                                [CRAM-MD5] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authCramMD5 )

                                [LOGIN] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authLogin )

                                [PLAIN] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authPlain )

                                [XOAUTH2] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authXOAuth2 )

                                [OAUTHBEARER] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authOAuthBearer )

                            )

                        [pipelining] => 
                        [pipelined_commands:protected] => 0
                        [debug:protected] => 
                        [debug_handler:protected] => 
                        [socket:protected] => Net_Socket Object
                            (
                                [_debug] => 
                                [_default_error_mode] => 
                                [_default_error_options] => 
                                [_default_error_handler] => 
                                [_error_class] => PEAR_Error
                                [_expected_errors] => Array
                                    (
                                    )

                                [fp] => 
                                [blocking] => 1
                                [persistent] => 
                                [addr] => mail.example.com
                                [port] => 465
                                [timeout] => 
                                [lineLength] => 2048
                                [newline] => 

                            )

                        [socket_options:protected] => Array
                            (
                            )

                        [timeout:protected] => 0
                        [code:protected] => -1
                        [arguments:protected] => Array
                            (
                            )

                        [greeting:protected] => 
                        [esmtp:protected] => Array
                            (
                            )

                        [gssapi_principal:protected] => 
                        [gssapi_cname:protected] => 
                        [scram_sha_hash_algorithm:protected] => 
                    )

                [_extparams] => Array
                    (
                    )

                [host] => mail.example.com
                [port] => 465
                [starttls] => 
                [auth] => 1
                [username] => [valid_fromt_email @ address.tld]
                [password] => -------------------------
                [localhost] => localhost
                [timeout] => 
                [debug] => 
                [debug_handler] => 
                [greeting] => 
                [persist] => 
                [pipelining] => 
                [socket_options] => Array
                    (
                    )

                [response] => 
                [queued_as] => 
            )

        [type] => ->
        [args] => Array
            (
            )

    )

[5] => Array
    (
        [file] => /[__SERVER__PATH__]/php/Mail/smtp.php
        [line] => 319
        [function] => send_or_fail
        [class] => Mail_smtp
        [object] => Mail_smtp Object
            (
                [sep] => 

                [_smtp] => Net_SMTP Object
                    (
                        [host] => mail.example.com
                        [port] => 465
                        [localhost] => localhost
                        [auth_methods] => Array
                            (
                                [SCRAM-SHA-512] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authScramSHA512 )

                                [SCRAM-SHA-384] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authScramSHA384 )

                                [SCRAM-SHA-256] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authScramSHA256 )

                                [SCRAM-SHA-224] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authScramSHA224 )

                                [SCRAM-SHA-1] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authScramSHA1 )

                                [DIGEST-MD5] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authDigestMD5 )

                                [CRAM-MD5] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authCramMD5 )

                                [LOGIN] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authLogin )

                                [PLAIN] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authPlain )

                                [XOAUTH2] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authXOAuth2 )

                                [OAUTHBEARER] => Array
                                    (
                                        [0] => Net_SMTP Object

RECURSION [1] => authOAuthBearer )

                            )

                        [pipelining] => 
                        [pipelined_commands:protected] => 0
                        [debug:protected] => 
                        [debug_handler:protected] => 
                        [socket:protected] => Net_Socket Object
                            (
                                [_debug] => 
                                [_default_error_mode] => 
                                [_default_error_options] => 
                                [_default_error_handler] => 
                                [_error_class] => PEAR_Error
                                [_expected_errors] => Array
                                    (
                                    )

                                [fp] => 
                                [blocking] => 1
                                [persistent] => 
                                [addr] => mail.example.com
                                [port] => 465
                                [timeout] => 
                                [lineLength] => 2048
                                [newline] => 

                            )

                        [socket_options:protected] => Array
                            (
                            )

                        [timeout:protected] => 0
                        [code:protected] => -1
                        [arguments:protected] => Array
                            (
                            )

                        [greeting:protected] => 
                        [esmtp:protected] => Array
                            (
                            )

                        [gssapi_principal:protected] => 
                        [gssapi_cname:protected] => 
                        [scram_sha_hash_algorithm:protected] => 
                    )

                [_extparams] => Array
                    (
                    )

                [host] => mail.example.com
                [port] => 465
                [starttls] => 
                [auth] => 1
                [username] => [valid_fromt_email @ address.tld]
                [password] => -------------------------
                [localhost] => localhost
                [timeout] => 
                [debug] => 
                [debug_handler] => 
                [greeting] => 
                [persist] => 
                [pipelining] => 
                [socket_options] => Array
                    (
                    )

                [response] => 
                [queued_as] => 
            )

        [type] => ->
        [args] => Array
            (
                [0] => [valid to email @ address.tld]
                [1] => Array
                    (
                        [MIME-Version] => 1.0
                        [Date] => Tue, 02 Jul 2024 12:17:44 +0000
                        [From] =>  <[valid_fromt_email @ address.tld]>
                        [Subject] => Contact from John
                        [To] => [valid to email @ address.tld]
                        [Content-Type] => multipart/alternative;

boundary="=_5d80c22efa979cad342450dbe04c818d" )

                [2] => --=_5d80c22efa979cad342450dbe04c818d

Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1

[removed]

--=_5d80c22efa979cad342450dbe04c818d Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1

[removed]

            )

    )

John
  • 138
  • 11

1 Answers1

1

It is far from clear what the architecture of this is / what you changed. If all you have done is to upgrade PHP on a host which was previously able to connect, then the issue is unlikely to have been caused by the PHP upgrade. Rollback the changes and test again.

Your exim log entry suggests that there is at least partial connectivity. But testing the connectivity would be a quicker/less disruptive for test. Can you ping the SMTP server host from the PHP host? Can you connect to the port using (e.g.) netcat?

It looks as if you are trying to use SMTPS here - but I would expect an error like this if the client were trying to connect WITHOUT using TLS. If the network connectivity tests are OK, you can test the TLS connection with openssl's s_client. e.g.

openssl s_client -connect mail.example.com:465
symcbean
  • 23,767
  • 2
  • 38
  • 58