feat: add email sending test script
Add sent-mail-tester.mjs for testing email functionality 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
27
email-server-worker/sent-mail-tester.mjs
Normal file
27
email-server-worker/sent-mail-tester.mjs
Normal file
@@ -0,0 +1,27 @@
|
||||
import FormData from "form-data"; // form-data v4.0.1
|
||||
import Mailgun from "mailgun.js"; // mailgun.js v11.1.0
|
||||
|
||||
async function sendSimpleMessage() {
|
||||
const mailgun = new Mailgun(FormData);
|
||||
const mg = mailgun.client({
|
||||
username: "api",
|
||||
key: process.env.API_KEY || "f581edcac21ec14d086ef25e36f04432-e61ae8dd-e207f22b",
|
||||
// When you have an EU-domain, you must specify the endpoint:
|
||||
url: "https://api.eu.mailgun.net"
|
||||
});
|
||||
try {
|
||||
console.log("Sending email...");
|
||||
const data = await mg.messages.create("rezije.app", {
|
||||
from: "Mailgun Sandbox <support@rezije.app>",
|
||||
to: ["Nikola Derezic <nikola.derezic@gmail.com>"],
|
||||
subject: "Hello Nikola Derezic",
|
||||
text: "Congratulations Nikola Derezic, you just sent an email with Mailgun! You are truly awesome!",
|
||||
});
|
||||
|
||||
console.log(data); // logs response data
|
||||
} catch (error) {
|
||||
console.log(error); //logs any error
|
||||
}
|
||||
}
|
||||
|
||||
sendSimpleMessage();
|
||||
Reference in New Issue
Block a user