vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.63k stars 995 forks source link

EmailPlugin does not work when I deployed my app #3063

Open rafapsm opened 3 weeks ago

rafapsm commented 3 weeks ago

Hi @michaelbromley,

I deployed my app and tried to test the emails and locally they work fine but when deployed I don't receive them.

Here's my config:

EmailPlugin.init({
      route: 'mailbox',
      devMode: IS_LOCAL ? true : undefined,
      outputPath: path.join(__dirname, '../static/email/test-emails'),
      handlers: [
        ...defaultEmailHandlers,
        administratorCreatedHandler,
        customerDeletionHandler,
        extendedEmailVerificationHandler,
        extendedPasswordResetHandler,
        priceDropNotificationHandler,
        propAddedToSavedSearch,
        UserInfoSubmittedHandler
      ],
      templateLoader: new FileBasedTemplateLoader(path.join(__dirname, './email-templates')),
      templatePath: path.join(__dirname, './email-templates'),
      transport: {
        type: 'smtp',
        host: process.env.MAILGUN_SMTP_SERVER || '',
        port: process.env.MAILGUN_SMTP_PORT ? +process.env.MAILGUN_SMTP_PORT : undefined,
        auth: {
          user: process.env.MAILGUN_SMTP_LOGIN || '',
          pass: process.env.MAILGUN_SMTP_PASSWORD || ''
        },
        logging: true,
        debug: true,
      },
      globalTemplateVars: {
        // The following variables will change depending on your storefront implementation
        fromAddress: '"QUATRU" <noreply@quatru.pt>',
        verifyEmailAddressUrl: ((process.env.URL_FRONTEND as string) + process.env.ENDPOINT_VERIFY_ACCOUNT) as string,
        passwordResetUrl: ((process.env.URL_FRONTEND as string) + process.env.ENDPOINT_RECOVER_PASSWORD) as string,
        changeEmailAddressUrl: ((process.env.URL_FRONTEND as string) + process.env.ENDPOINT_VERIFY_ACCOUNT) as string,
        privacyPolicyUrl: ((process.env.URL_FRONTEND as string) + process.env.ENDPOINT_PRIVACY_POLICY) as string,
        termsAndConditionsUrl: ((process.env.URL_FRONTEND as string) + process.env.ENDPOINT_TERMS_AND_CONDITIONS) as string,
        appleStoreUrl: process.env.APPLE_STORE_URL as string,
        googlePlayUrl: process.env.GOOGLE_PLAY_URL as string
      }
    }),

I'm using vendure 2.3.0

Can you help with this?

Thanks!

colinpieper commented 3 weeks ago

Are you getting any errors or logging output?

You seem to be using Mailgun. Is your Mailgun domain in the EU zone? If so, are you using the correct SMTP server (smtp.eu.mailgun.org)?

rafapsm commented 3 weeks ago

Are you getting any errors or logging output?

You seem to be using Mailgun. Is your Mailgun domain in the EU zone? If so, are you using the correct SMTP server (smtp.eu.mailgun.org)?

I don't get any error and my email events seems to be called. Also, my Mailgun domain is in the US zone, so SMTP server is smtp.mailgun.org. I upgrade the version of my vendure recently and I don't know if it is related.

rafapsm commented 2 weeks ago

Are you getting any errors or logging output?

You seem to be using Mailgun. Is your Mailgun domain in the EU zone? If so, are you using the correct SMTP server (smtp.eu.mailgun.org)?

I got this log The EmailPlugin is running in dev mode.

colinpieper commented 2 weeks ago

It sounds like devMode is set to true. I'm not sure what the variable IS_LOCAL is set to, as it's outside of the scope of your code snippet, but it sounds like it might be evaluating to true in your deployment environment.

If this doesn't help in finding the cause, I'd recommend asking for assistance in Discord instead (https://vendure.io/community). It's more suitable for these kinds of questions than GitHub issues, as the cause looks like a configuration/setup issue instead of a bug in Vendure itself.