Skip to content

Core Module - Mail

To it’s core, firstly provides you the ability to send emails. For this, we didn’t reinvent the wheel and use the great nodemailer package.

Anywhere in your code you can then:

import { remult } from 'remult'
await remult.context.sendMail('my_first_mail', {
to: '...@...',
subject: 'Hello from firstly',
html: 'hello <b>hello</b> 👋',
})

By default, firstly will create a demo account on ethereal.email, this will NEVER send a real email, but you can see the email sent in the ethereal dashboard. You also get a link to the email preview in the console.

Instead of passing the html param, you can pass templateProps, and it will use a nice default template.

import { sendMail } from 'firstly/mail/server'
await sendMail('my_second_mail', {
to: '...@...',
subject: 'Hello from firstly (a second time)',
templateProps: {
title: 'firstly 👋',
previewText: 'This is the mail you were waiting for',
sections: [
{
text: 'Then, How are you today ?',
highlighted: true,
},
{
text: 'Did you star the repo ?',
cta: {
text: 'Check it out',
link: 'https://github.com/jycouet/firstly',
},
},
],
},
})
export const api = firstly({
mail: {
transport: {
host: '...',
port: 587,
secure: false, // Use `true` for port 465, `false` for all other ports
auth: {
user: '...',
pass: '...',
},
},
},
})
export const api = firstly({
mail: {
// Like this you don't need to pass the `from` param in every call
from: {
name: 'My Cool App',
address: 'noreply@coolApp.io'
}
template: {
component: AnySvelteComponent
// to match your own branding
brandColor: '#E10098'
}
}
})