Very long it works out a script to send an email using the PhpMailer

Help me please! When sending email messages php script in the browser worked through about 2 minutes, but all messages are delivered. there are no errors on other SMTP servers is the same

PHP code


$mail = new PHPMailer;

$mail->Host = '';

$mail->SMTPAuth = true;

$mail->Username = '';

$mail->Password = '********';

$mail->SMTPSecure = 'ssl';

$mail->Port = '465';
 $mail->debug = true;

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

$mail->From = '';
$mail->FromName = 'Админ';
$mail->Subject = 'Тест Темы письма';
$mail->Body = 'тестовый текс Текст можно с  хтмл';
if( $mail->send() ){
    echo 'Письмо отправлено';
    echo 'Письмо не может быть отправлено. ';
    echo 'Ошибка: ' . $mail->ErrorInfo;

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

One possible reason for this type of delay is if defaults to ipv6 as gmail does PHPMailer will first attempt to reach the SMTP service by it’s ipv6 address. Whle we provide ipv6 support if you enable it on your droplet we do not allow SMTP traffic over ipv6 so this first attempt would be blocked. Trying the ipv4 address would then connect successfully.

Try replacing this:

$mail->Host = '';

with this, in your script

$mail->Host = gethostbyname("");

If the issue is an ipv6 attempt it should then be resolved. If you continue to see these long waits after this change, let us know here.

This comment has been deleted