🐝 ✉️ MailHog & Wasp: Testing Emails Locally

What is Wasp

I’ll assume you already know Wasp, it’s basically a Full-Stack framework similar to Laravel but for Javascript. If you don’t know anything about it yet, then I guess this is a sign that you should start exploring now.

For more …


This content originally appeared on DEV Community and was authored by Medard Mandane

What is Wasp

I'll assume you already know Wasp, it's basically a Full-Stack framework similar to Laravel but for Javascript. If you don't know anything about it yet, then I guess this is a sign that you should start exploring now.

For more information, please check their website -> Wasp-lang. Please read about OpenSaaS as well.

What is MailHog

  • Mailhog is an open source email testing tool that works locally. That only means you don't need internet to test emails.
  • To install MailHog, please check their GitHub repository for more info

How to use MailHog in Wasp

Step 1: In main.wasp file

  • set the email sender provider to SMTP
// main.wasp file
emailSender: {
...
  provider: SMTP
...
}

Step 2: Update .env.server

  • To use MailHog, simply set the SMTP configuration with the following values:
SMTP_HOST=localhost
SMTP_PORT=1025
SMTP_USERNAME=mailhog
SMTP_PASSWORD=mailhog
  • Usually you don't need to set the SMTP_USERNAME and SMTP_PASSWORD, however this won't work as Wasp uses nodemailer and the secured option is set to true by default if not specified.
    • Currently, there's no way to override that option. This works because I also don't know, maybe it's related to encryption or some restriction of nodemailer. Maybe you can help me explain it more 😁

Step 3: Testing

  • Open the web interface of MailHog, this is where you will receive all the emails sent through Wasp, you can access it @ localhost:8025 or 0.0.0.0:8025
  • Try sending an email, if you are using the OpenSaaS template, you can simply try reset password.

opensaas template reset password

  • You should receive the email email received in mailhog

If these instructions doesn't work and you found a working solution, please let me know :) I only tested this on a mac machine


This content originally appeared on DEV Community and was authored by Medard Mandane


Print Share Comment Cite Upload Translate Updates
APA

Medard Mandane | Sciencx (2024-07-26T21:53:17+00:00) 🐝 ✉️ MailHog & Wasp: Testing Emails Locally. Retrieved from https://www.scien.cx/2024/07/26/%f0%9f%90%9d-%e2%9c%89%ef%b8%8f-mailhog-wasp-testing-emails-locally/

MLA
" » 🐝 ✉️ MailHog & Wasp: Testing Emails Locally." Medard Mandane | Sciencx - Friday July 26, 2024, https://www.scien.cx/2024/07/26/%f0%9f%90%9d-%e2%9c%89%ef%b8%8f-mailhog-wasp-testing-emails-locally/
HARVARD
Medard Mandane | Sciencx Friday July 26, 2024 » 🐝 ✉️ MailHog & Wasp: Testing Emails Locally., viewed ,<https://www.scien.cx/2024/07/26/%f0%9f%90%9d-%e2%9c%89%ef%b8%8f-mailhog-wasp-testing-emails-locally/>
VANCOUVER
Medard Mandane | Sciencx - » 🐝 ✉️ MailHog & Wasp: Testing Emails Locally. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/26/%f0%9f%90%9d-%e2%9c%89%ef%b8%8f-mailhog-wasp-testing-emails-locally/
CHICAGO
" » 🐝 ✉️ MailHog & Wasp: Testing Emails Locally." Medard Mandane | Sciencx - Accessed . https://www.scien.cx/2024/07/26/%f0%9f%90%9d-%e2%9c%89%ef%b8%8f-mailhog-wasp-testing-emails-locally/
IEEE
" » 🐝 ✉️ MailHog & Wasp: Testing Emails Locally." Medard Mandane | Sciencx [Online]. Available: https://www.scien.cx/2024/07/26/%f0%9f%90%9d-%e2%9c%89%ef%b8%8f-mailhog-wasp-testing-emails-locally/. [Accessed: ]
rf:citation
» 🐝 ✉️ MailHog & Wasp: Testing Emails Locally | Medard Mandane | Sciencx | https://www.scien.cx/2024/07/26/%f0%9f%90%9d-%e2%9c%89%ef%b8%8f-mailhog-wasp-testing-emails-locally/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.