Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmailPlugin: Allow Email SMTP settings per channel #2043

Closed
martijnvdbrug opened this issue Feb 21, 2023 · 3 comments
Closed

EmailPlugin: Allow Email SMTP settings per channel #2043

martijnvdbrug opened this issue Feb 21, 2023 · 3 comments
Assignees

Comments

@martijnvdbrug
Copy link
Collaborator

martijnvdbrug commented Feb 21, 2023

Is your feature request related to a problem? Please describe.
I would like to be able to have different SMTP settings per channel, preferably stored in the database, so that administrators can configure their own mail server.

Describe the solution you'd like
My initial thought is to transform the transport property in the EmailPlugin.init() to a function, so that developers can dictate where SMTP settings are coming from:

    EmailPlugin.init({
      transport: async (ctx) => {

        // Get your SMTP settings based on the requestContext
        const settings = await myService.getSmtpSettings(ctx);

          return {
            type: 'smtp',
            host: settings.host,
            port: settings.port,
            auth: {
              user: settings.user,
              pass: settings.password,
            }
          }
          ...
    })

This way we can, for example, get SMTP config stored on custom fields on a Channel

Describe alternatives you've considered
I am currently using a transactional mail service, that also enables me to send emails from different domains with a single SMTP connection, which works fine, but all channels are forced to use the same transactional email service.

I would like to hear your thoughts on this. Is this something that should be included in Vendure, or is this a use case for a separate plugin?

Additional context

The process function is already async, so it shouldn't be to hard to resolve transport settings here:

await this.emailSender.send(emailDetails, this.transport);

@martijnvdbrug martijnvdbrug changed the title Allow Email SMTP settings per channel EmailPlugin: Allow Email SMTP settings per channel Feb 21, 2023
@martijnvdbrug
Copy link
Collaborator Author

For future reference @is0utfitters

@michaelbromley
Copy link
Member

Yes this proposal seems reasonable. We would also need to expose an injector instance so that you can inject your services into the method.

@martijnvdbrug
Copy link
Collaborator Author

Thanks for the response, can you assign this to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants