ReplyTo

Does gadget mailer support a custom replyTo? I'm using sendgrid. Below is my boot file
import { emails } from "gadget-server";
import type { Server } from "gadget-server";

/**
* Boot plugin to configure SendGrid as the email transport provider
* This plugin runs on app startup and configures the Gadget email system
* to use SendGrid for sending emails.
*/
export default async function plugin(server: Server) {
try {
// Get SendGrid API key from environment variables
const sendgridApiKey = process.env.SENDGRID_API_KEY;

if (!sendgridApiKey) {
throw new Error("SENDGRID_API_KEY environment variable is not set");
}

// Configure SendGrid transport
const transport = {
host: "smtp.sendgrid.net",
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: "apikey", // SendGrid requires this value to be "apikey"
pass: sendgridApiKey,
},
};

// Set the transport for Gadget emails
emails.setTransport(transport);

server.log.info("SendGrid email transport configured successfully");
} catch (error) {
// Log the error but don't crash the app
server.log.error(error, "Failed to configure SendGrid email transport");

// Depending on requirements, you might want to rethrow the error to prevent app startup
// if email functionality is critical
// throw error;
}
}
import { emails } from "gadget-server";
import type { Server } from "gadget-server";

/**
* Boot plugin to configure SendGrid as the email transport provider
* This plugin runs on app startup and configures the Gadget email system
* to use SendGrid for sending emails.
*/
export default async function plugin(server: Server) {
try {
// Get SendGrid API key from environment variables
const sendgridApiKey = process.env.SENDGRID_API_KEY;

if (!sendgridApiKey) {
throw new Error("SENDGRID_API_KEY environment variable is not set");
}

// Configure SendGrid transport
const transport = {
host: "smtp.sendgrid.net",
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: "apikey", // SendGrid requires this value to be "apikey"
pass: sendgridApiKey,
},
};

// Set the transport for Gadget emails
emails.setTransport(transport);

server.log.info("SendGrid email transport configured successfully");
} catch (error) {
// Log the error but don't crash the app
server.log.error(error, "Failed to configure SendGrid email transport");

// Depending on requirements, you might want to rethrow the error to prevent app startup
// if email functionality is critical
// throw error;
}
}
4 Replies
Jay
JayOP5mo ago
This is my current send code
await emails.sendMail({
to: shopOwnerAddress,
from: {
address: fromEmail,
name: "....",
},
subject: `Billing Receipt -...`,
html: renderedTemplate,
});
await emails.sendMail({
to: shopOwnerAddress,
from: {
address: fromEmail,
name: "....",
},
subject: `Billing Receipt -...`,
html: renderedTemplate,
});
I want a seperate reply to then the from email
Chocci_Milk
Chocci_Milk5mo ago
Hello, have you tried looking at these docs to see if we support any of these options? https://www.nodemailer.com/message/
Message configuration :: Nodemailer
Nodemailer is a module for Node.js to send emails
Chocci_Milk
Chocci_Milk5mo ago
If not, could you please add a feature request for it?
Jay
JayOP5mo ago
https://www.nodemailer.com/message/#routing-options includes a replyTo, but gagdet doesn't seem to support it. I will create request
Message configuration :: Nodemailer
Nodemailer is a module for Node.js to send emails

Did you find this page helpful?