diff --git a/server-example/src/sendEmail.ts b/server-example/src/sendEmail.ts
index 38f178c..5d70fb6 100644
--- a/server-example/src/sendEmail.ts
+++ b/server-example/src/sendEmail.ts
@@ -2,10 +2,9 @@ import { SMTPClient, SendConfig } from "https://deno.land/x/denomailer/mod.ts";
import { html } from "https://deno.land/x/html/mod.ts";
import { load } from "https://deno.land/std@0.193.0/dotenv/mod.ts";
-await load({ allowEmptyValues: true, examplePath: "" });
+const envs = await load({ allowEmptyValues: true, examplePath: "" });
-const emailTo =
- Deno.env.get("SMTP_RECEIVER") || Deno.env.get("SMTP_SENDER") || "";
+const emailTo = envs["SMTP_RECEIVER"] || envs["SMTP_SENDER"] || "";
export default (payload: FeedbackPayload) => {
if (emailTo)
@@ -35,12 +34,12 @@ const formatEmailContent = (payload: FeedbackPayload) => html`
const sendEmail = async (config: Omit) => {
const client = new SMTPClient({
connection: {
- hostname: Deno.env.get("SMTP_HOST") || "",
- port: parseInt(Deno.env.get("SMTP_PORT") || "587"),
- tls: Deno.env.get("SMTP_TLS") === "true",
+ hostname: envs["SMTP_HOST"] || "",
+ port: parseInt(envs["SMTP_PORT"] || "587"),
+ tls: envs["SMTP_TLS"] === "true",
auth: {
- username: Deno.env.get("SMTP_USERNAME") || "",
- password: Deno.env.get("SMTP_PASSWORD") || "",
+ username: envs["SMTP_USERNAME"] || "",
+ password: envs["SMTP_PASSWORD"] || "",
},
},
});
@@ -49,7 +48,7 @@ const sendEmail = async (config: Omit) => {
console.log(`Send email notification to ${emailTo}`);
const response = await client.send({
...config,
- from: Deno.env.get("SMTP_SENDER") || "sender@example.org",
+ from: envs["SMTP_SENDER"] || "sender@example.org",
});
await client.close();