When using SMTP mail from the WordPress mail plugin, and it fails with an error like this:
Connection: Failed to connect to server. Error number 2. “Error notice: stream_socket_client(): unable to connect to someserver.com:587 (Connection refused)
Try to make a telnet connection to the destimation server from the command line on the server first.
telnet someserver.com 587 (or 25 depending on the port).
If that works, then check if you have a CSF (ConfigServer Firewall) installed. If you do, check for “SMTP_BLOCK” in the csf.conf file. If this is enabled, then CSF is blocking the connection. If it is, you can get around this 2 ways.
- disable it by changing the 1 to a 0
- allow the user to bypass it by adding his username to the “SMTP_ALLOWUSER” field
Once you have made the change, restart CSF, and you should be all set.