Resend Client Email
fredericomaia:email-resend is a package that simplifies the process of sending emails using Meteor. It provides a plug-and-play integration with Resend, leveraging the powerful email package from Meteor.
Installation
To install fredericomaia:email-resend, simply execute the following command:
meteor add fredericomaia:email-resend
Usage
Resend
Create a Resend account, create an API Key and verify your domain.
Configuration
To get started quickly with using Resend as the email provider for Meteor, you only need to configure your API Key in your settings. Modify your settings file as follows:
1{ 2 "packages": { 3 "fredericomaia:email-resend": { 4 "from": "noreply@yourdomain.com", 5 "apiKey": "re_aAAaAAAA_0a0AaAAaAaAaaaaaAa0AaAAA" 6 } 7 } 8}
| Setting | Required | Description |
|---|---|---|
apiKey | Yes (unless devMode) | Your Resend API key |
from | No | Default sender address. Can be overridden per call. |
devMode | No | When true, emails are logged to the console instead of sent. apiKey is not required. |
isVerbose | No | When true, logs a success message after each email sent via Email.customTransport. |
Usage
Automatically used when calling methods from the Email and Accounts Password packages. For example when calling Accounts functions as Accounts.sendVerificationEmail(), Accounts.forgotPassword(), Accounts.sendResetPasswordEmail(), and so on.
You can also use this package to send emails directly. Here's an example of how to do it:
1import { Meteor } from 'meteor/meteor'; 2import { sendEmail } from 'meteor/fredericomaia:email-resend'; 3 4Meteor.methods({ 5 async sendMyRandomEmail({ to, subject, content }) { 6 try { 7 await sendEmail({ to, subject, content }); 8 console.log(`Email sent to ${to}`); 9 } catch (error) { 10 console.error(`Error sending email to ${to}`, error); 11 } 12 } 13});
You can optionally provide the from field in the sendEmail function if you haven't set it in the package settings.
Limitations
Requires Meteor 3.0 or above.
License
This project is licensed under the MIT license.