A
A
Aricus2019-09-09 12:04:31
PHP
Aricus, 2019-09-09 12:04:31

Where is the error when connecting to SMTP gmail using fsockopen?

I will say right away that I do not understand web sockets at all. I'm trying to send an email via SMTP gmail. I took the code from the Internet, and received an error at the stage of establishing a connection.

$smtp_host = 'ssl://smtp.gmail.com';
$smtp_port = 465;
if (!($socket = fsockopen($smtp_host, $smtp_port, $errno, $errstr, 15)))
echo "Could not connect to smtp host ($errno) ($errstr)";

Could not connect to smtp host(0)()

The documentation says:
If the value of the errno parameter is 0 and the function returns FALSE, then the error occurred before the connect() call. In most cases, this indicates problems with socket initialization.

But what exactly is the problem, I don't understand.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2019-09-09
@Aricus

the doc says that stream_socket_client() is preferable, also check if the protocol is available with the stream_get_transports() function. Check the connection to another server, perhaps this one is not responding for some reason.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question