RejectedSoftware Forums

Sign up

Can't send email

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

Re: Can't send email

Sorry for incompilable code :)

Config.smtp and smtp is the same config object, I am just a bad copypaster.

Re: Can't send email

On Wed, 24 Dec 2014 12:51:20 GMT, Maaaks wrote:

smtp.sslValidationMode = SSLPeerValidationMode.trustedCert;

This is probably the reason for the error. For this to succeed, you'd also have to set smtp.sseContextSetup (mind the typo) and add some trusted certificates to the context using SSLContext.useTrustedCertificateFile.

Setting SSLPeerValidationMode.validCert would skip the trust check and should also eliminate the error message.

Re: Can't send email

Didn't help. :-(

I also tried none, it didn't help, too.

Re: Can't send email

On Sun, 28 Dec 2014 00:44:46 GMT, Maaaks wrote:

Didn't help. :-(

I also tried none, it didn't help, too.

I've added a ticket for now and will have another look later: #954

Re: Can't send email

On Sun, 28 Dec 2014 00:44:46 GMT, Maaaks wrote:

Didn't help. :-(

I also tried none, it didn't help, too.

I think (correct me if I'm wrong) you still have an old version of Vibe.d which do not print an useful message out of OpenSSL, maybe try to update and see if that helps.