rszab003
rszab003
HHono
Created by rszab003 on 1/22/2025 in #help
How can I use hono/jsx templates to send Emails via Nodemailer?
I didn't know the raw function could do that. This is generally how I got templated emails working with hono:
import nodemailer from "nodemailer";
import type {Transporter, SentMessageInfo} from "nodemailer";
import Email from "./Email";
import { raw } from "hono/html";

async function main() {
const recipientName: string = "name";
const email: string = raw(<Email name={recipientName}/>).toString(); // nodemailer expects plain string
console.log(email);

const transporter: Transporter = nodemailer.createTransport({
host: 'smtp.yourhost.ch',
port: 465,
secure: true, // 465 or 587
auth: {
user: 'your@email.com',
pass: '...'
},
});

const info: SentMessageInfo = await transporter.sendMail({
from: '"name :ghost:" <your@email.com>', // sender address
to: 'to@email.com', // list of receivers
subject: `HELLO!? ${recipientName}`, // Subject line
html: email
});
}

main().catch(console.error);
import nodemailer from "nodemailer";
import type {Transporter, SentMessageInfo} from "nodemailer";
import Email from "./Email";
import { raw } from "hono/html";

async function main() {
const recipientName: string = "name";
const email: string = raw(<Email name={recipientName}/>).toString(); // nodemailer expects plain string
console.log(email);

const transporter: Transporter = nodemailer.createTransport({
host: 'smtp.yourhost.ch',
port: 465,
secure: true, // 465 or 587
auth: {
user: 'your@email.com',
pass: '...'
},
});

const info: SentMessageInfo = await transporter.sendMail({
from: '"name :ghost:" <your@email.com>', // sender address
to: 'to@email.com', // list of receivers
subject: `HELLO!? ${recipientName}`, // Subject line
html: email
});
}

main().catch(console.error);
7 replies
HHono
Created by rszab003 on 1/22/2025 in #help
How can I use hono/jsx templates to send Emails via Nodemailer?
thanks for your response @ambergristle ... is it possible to template an email with this helper?
7 replies