Set up a custom support email
Set up Transactional Emails
Transactional emails are automated emails triggered by a user action or event related to their account. Examples include verification (OTP) emails, message notifications etc. They are different to marketing emails which are broadcast to a broad audience for promotional purposes. Since marketing emails tend to be time-sensitive and must be reliably delivered, they are typically sent by specialised services like ZeptoMail which focus on high inbox placement and speed as opposed to marketing platforms that send to large subscriber lists.
ZeptoMail was chosen for SvelteStart because of it's cheap cost. Rather than a monthly payment scheme, you pay a couple of dollars for a credit which gives you 10,000 emails that are valid for 6 months. Currently, it's only used for sending OTPs but you can extend this for other purposes as you build out your app. If you want to use a different transactional email provider like Mailgun or SendGrid, you can do this but you'll have to call their API when sending an email e.g. in sendVerificationEmail().
Let's get started. First, create an account with ZeptoMail and purchase a credit. Then, go to the 'Domains' page and add your domain. You'll see two two records listed there.
DKIM is used for verifying that emails sent from your domain are genuinely from you. Every outgoing email will be signed with a private DKIM key to hash the email content/headers. The receiving mail server retrieves the corresponding public key from your domain's DNS to verify the signature.
The CNAME record maps a custom bounce subdomain e.g. 'bounce-zem' to ZeptoMail's servers so they can retrieve and track bounced (failed) outgoing emails on your behalf. Your outgoing emails should specify this bounce address so that the recipient' mail sever can can send a bounce message to that address on failure.
Note that adding these records may take up to a couple of hours to kick in. You can check by clicking the 'Verify domain' button.

Once completed, toggle on the 'Sender Address Configuration' and add your sender address e.g. 'support@yourdomain.com'. After this is set up, create a new mail agent from the sidebar and fill in the form. The mail agent name can be the name of your app, and associate domain is what you just added before.
Now open the page for that mail agent, and go to the 'SMTP/API' tab. On this page, click 'API' and copy the 'Send Mail token 1'. Paste this into your .env file as well as your staging and production environment variables as ZEPTOMAIL_MAIL_TOKEN=.... You are now ready to send transactional emails programmatically. Go back go to the Auth guide and complete the 'Setting up One-Time Passcode (OTP)' section.
Last updated