Hello. I can't send an email using sendMail(). Here's the configuration I use:

smtp = new SMTPClientSettings;
smtp.authType = SMTPAuthType.login;
smtp.connectionType = SMTPConnectionType.startTLS;
smtp.sslValidationMode = SSLPeerValidationMode.trustedCert;
smtp.host = "smtp.yandex.ru";
smtp.port = 587;
smtp.localname = "localhost"; // or, what should I set here?
smtp.password = /*my password*/;
smtp.username = /*my email*/;

When I try to send email...

auto msg = new Mail;
msg.headers["From"] = Config.smtp.username~" <"~Config.smtp.username~">";
msg.headers["To"] = "<"~/*my other email*/~">";
msg.headers["Subject"] = "Some subject";
msg.headers["Content-Type"] = "text/plain; charset=UTF-8";
msg.bodyText = "Some body";
sendMail(smtp, msg);

I get an error:

Failed to connect SSL tunnel.: (0)

At the same time, I have no problem when sending email with the same configuration using SendEmail script:

sendemail -f /*my email*/ -t o@ololo.im -u "Тест Sendemail" -m 'Привет!\nКак насчёт получать мои письма?' -s smtp.yandex.ru:587 -xu /*my email*/ -xp /*my password*/ -o tls=yes