wasp/server/email
Send emails from your server code.
Only available if your app sets the emailSender field of the app spec.
Type Aliases
Email
Email =
object
An email to send with emailSender.send.
Properties
from?
optionalfrom?:EmailFromField
The sender's details.
It's optional if you set up the defaultFrom field of emailSender in
the app spec, and required otherwise.
html
html:
string
The HTML version of the email.
subject
subject:
string
The subject of the email.
text
text:
string
The text version of the email.
to
to:
string
The recipient's email address.
EmailFromField
EmailFromField =
object
The sender of an Email.
It has the sender's email address, and optionally their name.
Properties
email
email:
string
name?
optionalname?:string
EmailSender
EmailSender =
object
The type of emailSender.
Methods
send()
send(
Promise<any>
Sends an email.
Parameters
email
Returns
Promise<any>
The SentMessageInfo of the sent email.
SentMessageInfo
SentMessageInfo =
any
The status of a sent email, returned by
emailSender.send. It varies depending on the
provider you use.
Variables
emailSender
constemailSender:EmailSender
Sends emails with the provider you set up in the emailSender field of the
app spec.
Example
import { emailSender } from "wasp/server/email";
// In some action handler...
const info = await emailSender.send({
from: {
name: "John Doe",
email: "john@doe.com",
},
to: "user@domain.com",
subject: "Saying hello",
text: "Hello world",
html: "Hello <strong>world</strong>",
});