forked from manyuanrong/deno-smtp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.ts
43 lines (39 loc) · 1.05 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { SmtpClient } from "./smtp.ts";
import "https://deno.land/x/[email protected]/load.ts";
const { TLS, PORT, HOSTNAME, MAIL_USER, MAIL_TO_USER, MAIL_PASS } = Deno.env
.toObject();
const client = new SmtpClient();
const config = {
hostname: HOSTNAME,
port: PORT ? parseInt(PORT) : undefined,
username: MAIL_USER,
password: MAIL_PASS,
};
if (TLS) {
await client.connectTLS(config);
} else {
await client.connect(config);
}
await client.send({
from: MAIL_USER,
to: MAIL_TO_USER,
subject: "Deno Smtp build Success" + Math.random() * 1000,
content: "plain text email",
html: `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Deno Smtp build Success</title>
</head>
<body>
<h1>Success</h1>
<p>Build succeed!</p>
<p>${new Date()}</p>
</body>
</html>
`,
});
await client.close();