www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - vibe.d

reply seany <seany uni-bonn.de> writes:
Hi

I am trying to send an email via vibe .d

Here is the code snippet.

```
Mail email = new Mail;

	email.headers["Date"] = 
Clock.currTime(PosixTimeZone.getTimeZone("America/New_York")).toRFC
22DateTimeString(); // uses UFCS
	email.headers["Sender"] = "<<myapp_de.sean gmail.com>"; // valid 
mail
	email.headers["From"] = "<myapp_de.sean gmail.com>"; // valid 
email
	email.headers["To"] = "<seany domain.de>";  // valid mail.
	email.headers["Subject"] = "Betreff";
	email.headers["Content-Type"] = "text/plain;charset=utf-8";
	email.bodyText = "Textinfo";

	setLogLevel(LogLevel.verbose4);															writeln("00");



	auto settings = new SMTPClientSettings("smtp.gmail.com", 587);
	settings.connectionType = SMTPConnectionType.startTLS;
	settings.authType = SMTPAuthType.login;
	settings.username = "myapp_de.sean gmail.com";
	settings.password = "mypass_veryStronk";

	logInfo("Sending mail...");
     sendMail(settings, email);
     logInfo("done.");

	res.writeBody("An email has been sent to the user ");
```









I get this error :


```
[main(toaW) INF] Sending mail...
Thread exit Eventcore DNS Lookup (index 9) (main=false)
Socket 43, read 86 bytes: ok
Socket 43, read 192 bytes: ok
EHLO response: 250-smtp.gmail.com at your service, 
[2a02:3030:9:4f1a:bd94:4bec:9e39:c9fa]
EHLO response: 250-SIZE 35882577
EHLO response: 250-8BITMIME
EHLO response: 250-STARTTLS
EHLO response: 250-ENHANCEDSTATUSCODES
EHLO response: 250-PIPELINING
EHLO response: 250-CHUNKING
EHLO response: 250 SMTPUTF8
Socket 43, read 30 bytes: ok
Socket 43, read 2416 bytes: ok
Socket 43, read 1208 bytes: ok
Socket 43, read 572 bytes: ok
validate callback for /C=US/O=Google Trust Services LLC/CN=GTS 
Root R1
SSL cert initial error: unable to get local issuer certificate
SSL cert not trusted or unknown issuer: /C=BE/O=GlobalSign 
nv-sa/OU=Root CA/CN=GlobalSign Root CA
SSL validation result: 0 (20)
OpenSSL error at ssl/statem/statem_clnt.c:1889: 
error:0A000086:SSL routines::certificate verify failed (-)
---------------------
HTTP server response:
---------------------
HTTP/1.1 500 Internal Server Error
Server: vibe.d/1.22.6
Date: Sat, 11 Mar 2023 10:09:49 GMT
Keep-Alive: timeout=10
Content-Type: text/plain; charset=UTF-8
Content-Length: 6133
---------------------
Exception while handling request POST /createNewOwner: 
object.Exception /home/monsoon/.dub/packages/vibe-d-0.9.6-alpha.1/vibe-d/tls/vibe/st
eam/openssl.d(668): Connecting TLS tunnel: error:0A000086:SSL
routines::certificate verify failed (167772294)
```


Note that dub is running on localhost.

How can I resolve this? Please help. Thank you
Mar 11 2023
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 3/11/23 5:12 AM, seany wrote:
     email.headers["Sender"] = "<<myapp_de.sean gmail.com>"; // valid mail
Looks like an extra `<`, is that correct?
 Exception while handling request POST /createNewOwner: 
 object.Exception /home/monsoon/.dub/packages/vibe-d-0.9.6-alpha.1/vibe-d/tls/vibe/st
eam/openssl.d(668): Connecting TLS tunnel: error:0A000086:SSL
routines::certificate verify failed (167772294)
 ```
 
 
 Note that dub is running on localhost.
 
 How can I resolve this? Please help. Thank you
Looks like an issue with the certificate, either on your vibe app or on the email server. -Steve
Mar 11 2023
parent seany <seany uni-bonn.de> writes:
On Saturday, 11 March 2023 at 12:56:16 UTC, Steven Schveighoffer 
wrote:
 On 3/11/23 5:12 AM, seany wrote:
     email.headers["Sender"] = "<<myapp_de.sean gmail.com>"; // 
 valid mail
Looks like an extra `<`, is that correct?
No, i mistyped that when i changed the email address after copying it in here. The original code does not have that extra < sign Thank you.
Mar 11 2023