D
D
Dymok2019-08-07 10:54:30
PHP
Dymok, 2019-08-07 10:54:30

Timeout when sending message via SMTP using PHPMailer?

There is a code:

$mail = new PHPMailer;
    $mail->CharSet = 'UTF-8';

// Настройки SMTP
    $mail->isSMTP();
    $mail->SMTPAuth = true;
    $mail->SMTPDebug = 3;

    $mail->Host = 'smtp.yandex.com';
    $mail->Port = 465;
    $mail->Username = '***@yandex.ru';
    $mail->Password = '***';



// От кого
    $mail->setFrom('***[email protected]', 'Snipp.ru');

// Кому
    $mail->addAddress('[email protected]', 'Иван Петров');

// Тема письма
    $mail->Subject = "Тема";

// Тело письма
    $body = '<p><strong>«Hello, world!» </strong></p>';
    $mail->msgHTML($body);

    //send the message, check for errors
    if (!$mail->send()) {
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        echo 'Message sent!';
    }

I turn to AJAX, as a result, after 3 minutes of waiting, the script execution time simply ends, in the console:
<br>2019-08-07 07:44:09 Connection: opening to smtp.yandex.com:465, timeout=300, options=array()<br>
2019-08-07 07:44:09 Connection: opened<br>
<br />
<b>Fatal error</b>:  Maximum execution time of 180 seconds exceeded in <b>D:\OSPanel\domains\blockchain.mcdir.local\vendor\phpmailer\phpmailer\src\SMTP.php</b> on line <b>1125</b><br />

I tried from my computer, from hosting, with the mail.ru SMTP server, the ping goes to the SMTP server. What else could be the problem? I've already broken my head.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gennady S, 2019-08-07
@UnluckySerivelha

Try setting up a secure connection:
$mail->SMTPSecure = 'tls';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question