Email not sending on production
Hey, I'm using the OpenSaaS template and Wasp 0.15, running on a self-hosted Coolify instance. When I sign up on my dev machine, I receive a verification email just fine. When I sign up in production (with the same env vars), no email is sent. I don't see anything in the logs regarding emails. Only on the client, there's a
10:52AM DBG Request Handled Method=POST Path=/auth/email/signup
line.
I've tried with both SMTP and Mailgun providers. When I look at the SMTP provider and Mailgun logs it looks as though they haven't received the request.
I ran a test script from the wasp server docker container to see if it could be a networking issue, but there I do receive the email just fine. Test script:
Any thoughts on what I'm missing?5 Replies
Hi @4YZ. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided in the knowledge sources, I don't have enough specific details to fully diagnose why emails are not being sent in your production environment while they work fine in development. However, I can offer some suggestions and insights based on the available information about Wasp's email functionality.
1. Email Provider Configuration:
Make sure you have properly configured your email provider in the production environment. As mentioned in the Sending Emails documentation, you need to set up the email sender in your
main.wasp
file and provide the necessary environment variables in your .env.server
file.
2. Environment Variables:
Double-check that all required environment variables for your chosen email provider (SMTP or Mailgun) are correctly set in your production environment. These should be in your .env.server
file on your Coolify instance.
3. Dummy Provider:
Ensure you're not using the Dummy provider in production, as it's meant only for development and will cause the build to fail in production, as stated in the Providers documentation.
4. Error Logging:
Since you mentioned not seeing any logs regarding emails, you might want to add more detailed error logging in your email sending code. This could help identify if the email sending process is being initiated and where it might be failing.
5. Network Issues:
Although your test script works, there might still be network-related issues specific to the email sending process in your production setup. Ensure that your Coolify instance has the necessary network access to communicate with your email provider.
6. Email Verification Flow:
Review your email verification setup as described in the Email Verification Flow documentation to ensure all components are correctly configured.
7. Custom Sign-up Action:
If you're using a custom sign-up action, make sure it's properly implemented and includes the email sending logic, as shown in the Creating a Custom Sign-up Action documentation.
Given that your test script works, the issue might be related to how the email sending is integrated into your authentication flow in the production environment. You might want to add more detailed logging or error handling around the email sending process in your sign-up logic to pinpoint where the process is breaking down.
If you continue to face issues, you may need to provide more detailed logs from your production environment or consider reaching out to the Wasp community on their Discord channel for more specific troubleshooting assistance.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @4YZ, 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?The env vars/provider should be set correctly, because the script could send the email from the container using wasp's own email sending function. I didn't change the sign up flow from the original email auth in the OpenSaaS template.
can you log something to the server console when sending an email and check to see if its working from both your app on signup, and your script @4YZ ?
Tagging @miho here too, as he is our Coolify and Auth wizard.
Thanks for your response. My bad, forgot to update the REACT_APP_API_URL in my deploy github action. It was set to example.com instead of api.example.com (where the server is hosted). So a POST to https://example.com/auth/email/signup should have been to https://api.example.com/auth/email/signup. Response code was 200 so I didn't look into it further but the actual response was: "You need to enable JavaScript to run this app." ie the client was sending a request to itself. Hence no logging on the server
Glad you got it working!