1 |
|
2 | * test smtp |
3 | * |
4 | */ |
5 | export async function main(body: { |
6 | to: string; |
7 | smtp: { |
8 | host: string; |
9 | username: string; |
10 | password: string; |
11 | port: number; |
12 | from: string; |
13 | tls_implicit: boolean; |
14 | [k: string]: unknown; |
15 | }; |
16 | [k: string]: unknown; |
17 | }) { |
18 | const url = new URL(`${BASE_URL}/api/settings/test_smtp`); |
19 |
|
20 | const response = await fetch(url, { |
21 | method: "POST", |
22 | headers: { |
23 | "Content-Type": "application/json", |
24 | Authorization: "Bearer " + WM_TOKEN, |
25 | }, |
26 | body: JSON.stringify(body), |
27 | }); |
28 | if (!response.ok) { |
29 | const text = await response.text(); |
30 | throw new Error(`${response.status} ${text}`); |
31 | } |
32 | return await response.text(); |
33 | } |
34 |
|