need a way to have different emailsender in dev and prod...

right now, when developing locally, i have to set the emailsender to dummy. then, before deploying, i need to set it to smtp. then, when running locally, back to dummy. over and over. sometimes i can do multiple deployments in a day, so this is significant friction, and if i forget, the prod environment will be set to dummy. there needs to be a way to have a main.wasp and a main.wasp.prod or some such, with the settings in the latter file overriding those in the default (dev) file. or vice versa, the mechanism doesn't matter as long as it's possible. thoughts?
2 Replies
kapa.ai
kapa.ai3w ago
Hi @johnwest6192. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I understand your frustration with having to switch between email providers for development and production environments. Currently, Wasp doesn't support dynamic configuration in the main.wasp file based on the environment. Current Situation As you've experienced, you need to manually change the email provider in your main.wasp file between: - Dummy for development (which just logs emails to the console) - SMTP or another provider for production This creates friction in your workflow and introduces the risk of accidentally deploying with the wrong configuration. Future Solutions The good news is that this is a recognized issue in Wasp: 1. The Wasp team is planning to implement a TypeScript-based configuration system that would allow for dynamic values based on environment variables. This is tracked in GitHub issue #551. 2. Another related issue has been opened specifically for environment-specific values in the main.wasp file: GitHub issue #1786. A Wasp team member confirmed in a Discord thread: "We don't support such dynamic variables atm, we are looking in the future (sooner than later) to have a TS based config which would enable all sorts of customisation for example, values based on local env vars" Discord discussion. Current Workarounds Until this feature is implemented, you'll need to continue manually changing the configuration. Some potential workflow improvements: 1. Use Git hooks to prevent committing the development configuration to your production branch 2. Create a simple script that modifies the main.wasp file before deployment 3. For email authentication specifically, you can use the SKIP_EMAIL_VERIFICATION_IN_DEV environment variable to avoid sending emails during development Email Auth Docs The Wasp team is aware of this pain point and is working toward a solution that would allow environment-specific configurations. I hope this helps clarify the current situation and future plans! ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @johnwest6192, 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?
genyus
genyus3w ago
This is achievable using Wasp TypeScript config:
import { EmailProvider } from 'wasp-config';

app.emailSender({
provider: process.env.EMAIL_PROVIDER as EmailProvider || 'Dummy',
defaultFrom: { email: '[email protected]' }
});
import { EmailProvider } from 'wasp-config';

app.emailSender({
provider: process.env.EMAIL_PROVIDER as EmailProvider || 'Dummy',
defaultFrom: { email: '[email protected]' }
});
Set the EMAIL_PROVIDER environment variable to SMTP in production and Dummy in dev.

Did you find this page helpful?