How to send emails with Mailgun
What code do I need to use to send emails with Mailgun?
5 Replies
Hi @ArDev. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To send emails with Mailgun in Wasp, you need to follow these steps:
1. Set the provider to
Mailgun
in the main.wasp
file:
Source (https://wasp-lang.dev/docs/advanced/email#using-the-mailgun-provider)
2. Get the Mailgun API key and domain and add them to your .env.server
file:
Source (https://wasp-lang.dev/docs/advanced/email#using-the-mailgun-provider)
3. Use the emailSender
from the wasp/server/email
module to send emails:
Source (https://wasp-lang.dev/docs/advanced/email#javascript-api)
Please note that the send
method accepts an object with the following fields: from
, to
, subject
, text
, and html
. The from
field is optional if you set up the defaultFrom
field in the emailSender
dict in the Wasp file.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @ArDev, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai how to get the api key?
Let me check the knowledge base for you. One moment! :books:
----------------------
To get the Mailgun API key, follow these steps:
1. Go to Mailgun (https://www.mailgun.com/) and create an account.
2. Go to API Keys (https://app.mailgun.com/app/account/security/api_keys) and create a new API key.
3. Copy the API key and add it to your
.env.server
file.
Your .env.server
file should look like this:
Replace your_api_key_here
with the API key you got from Mailgun.
Source (https://wasp-lang.dev/docs/advanced/email#using-the-mailgun-provider)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @ArDev, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai how to get server_url? how do i get it from railway
Let me check the knowledge base for you. One moment! :books:
----------------------
To get the server URL from Railway, follow these steps:
1. Go to your Railway dashboard (https://railway.app/dashboard).
2. Click on your project.
3. Go to the
server
instance's Settings
tab, and click Generate Domain
.
The generated domain is your server URL. You can use this URL as the WASP_SERVER_URL
in your environment variables.
Source (https://wasp-lang.dev/docs/advanced/deployment/manually#railway-server-client-and-database)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @ArDev, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?