Skip to content
⚠️ Open SaaS is now running on Wasp v0.13! If you're running an older version of Open SaaS, please follow the migration instructions here ⚠️

Email Sending

This guide explains how to use the integrated email sender and how you can integrate your own account in this template.

Sending Emails

The Dummy Email Provider (for Local Dev Only)

By default we’ve set up the email sender to use the Dummy provider. This is for local development only and no emails will actually be sent out! To obtain an email verification token/link, you must check the server logs on initial sign up. You can click this link to verify your email and continue with the sign up process.

main.wasp
app SaaSTemplate {
// ...
emailSender: {
provider: Dummy,
defaultFrom: {
name: "Open SaaS App",
email: "me@example.com"
},
},

Note that your app will not build if using the Dummy provider and you must switch to a production-ready provider in order to do so.

Using a Production-Ready Email Provider (e.g. SendGrid)

To change your email provider to a production-ready one, such as SendGrid, you’ll want to configure your emailSender like so:

main.wasp
app SaaSTemplate {
// ...
emailSender: {
provider: SendGrid,
defaultFrom: {
name: "Open SaaS App",
// When using SendGrid, you must use the same email address that you configured your account to send out emails with!
email: "me@example.com"
},
},

This means that you can send emails from your app using the send function from the email modul provided by Wasp:

src/server/webhooks.ts
import { emailSender } from "wasp/server/email";
//...
if (subscription.cancel_at_period_end) {
await emailSender.send({
to: customer.email,
subject: 'We hate to see you go :(',
text: 'We hate to see you go. Here is a sweet offer...',
html: 'We hate to see you go. Here is a sweet offer...',
});
}

In the example above, you can see that we’re sending an email to the customer when we receive a cancel subscription event within the Stripe webhook.

This is a powerful feature and super simple to use.

Integrate your email sender

To set up your email sender, you first need an account with one of the supported email providers.

  • Register at SendGrid.com and then get your API KEYS.
  • Copy yours to the .env.server file under the SENDGRID_API_KEY variable.

Make sure to change the defaultFrom email address in the main.wasp file to use the same email address that you configured your account to send out emails with!

main.wasp
emailSender: {
provider: SendGrid,
defaultFrom: {
name: "Open SaaS App",
email: "me@example.com" // <--- same email address you configured your SendGrid account to send emails with!
},

If you want more detailed info, or would like to use SMTP, check out the Wasp docs.