Error while sending an email

Hello.

When I am trying to send an email I’ve got an error
in vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php (line 445) Expected response code 250 but got an empty response

I use regular code from my previous projects.
$mail = new \Pimcore\Mail(); $mail->addTo('sgidlev@gmail.com'); $emailDocument = Document::getById(14); $mail->setDocument($emailDocument); $mail->send();

I set in setting Mail method and fill the email sender.

Are you using gmail ID to send emails? then maybe try to allow less secure apps option https://myaccount.google.com/lesssecureapps

Continuing the discussion from Error while sending an email:

I resolved it by using SMTP settings