Node.js SDK
Send email with Meteor
Use Parcel Wing from Meteor server methods and keep your API key in trusted server settings.
Install the SDK
Install the official SDK in your Meteor app with meteor npm.
Terminal
meteor npm install @parcelwing/node
Settings
Put your Parcel Wing API key in Meteor settings or deployment environment variables, then run Meteor with those settings locally.
settings.json
{"parcelWing": {"apiKey": "pw_live_...","fromEmail": "Acme <[email protected]>"}}
Terminal
meteor --settings settings.json
Server method
Define a Meteor method on the server that validates inputs, checks authorization, and sends a template email.
server/email-methods.ts
import { Meteor } from "meteor/meteor";import { check, Match } from "meteor/check";import { ParcelWing, ParcelWingError } from "@parcelwing/node";const parcelWing = new ParcelWing({apiKey: Meteor.settings.parcelWing.apiKey,});Meteor.methods({async "emails.sendWelcome"(params: { email: string; firstName?: string }) {check(params, {email: String,firstName: Match.Maybe(String),});if (!this.userId) {throw new Meteor.Error("not-authorized", "You must be signed in.");}try {const [message] = await parcelWing.emails.send({from: Meteor.settings.parcelWing.fromEmail,to: params.email,template_alias: "welcome_email",template_params: {first_name: params.firstName ?? "friend",},});return { id: message?.id };} catch (error) {if (error instanceof ParcelWingError) {throw new Meteor.Error(error.code ?? "parcel-wing-error","Parcel Wing could not send the email.",{ requestId: error.requestId },);}throw error;}},});
Client call
Call the method from the client. The API key stays on the server because the browser only invokes your Meteor method.
client/invite.ts
import { Meteor } from "meteor/meteor";Meteor.call("emails.sendWelcome",{ email: "[email protected]", firstName: "Ada" },(error: Meteor.Error | undefined, result?: { id?: string }) => {if (error) {console.error(error.reason, error.details);return;}console.log("Sent message", result?.id);},);
Production notes
- Do not put
PARCEL_WING_API_KEYin public settings. - Validate recipients and enforce authorization inside server methods.
- Use templates for common app emails such as invites, onboarding, and receipts.