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

How use Mailjet template #6

Open
TonyTR opened this issue Nov 27, 2020 · 2 comments
Open

How use Mailjet template #6

TonyTR opened this issue Nov 27, 2020 · 2 comments

Comments

@TonyTR
Copy link

TonyTR commented Nov 27, 2020

hello @ScottAgirsit is possible to add the options of param the possibility of using a template ? (https://dev.mailjet.com/email/guides/template-api/) -> TemplateID: 1,
with for example :
settings: {
defaultTemplateId: 1,
}

@ScottAgirs
Copy link
Contributor

Hey @TonyTR , thanks for opening this suggestion.
Would you be interested in taking this on? If not then this could potentially be added early next year.

@yosle
Copy link

yosle commented Jan 30, 2023

In case someone need this. You can acctually send templates , just need to add the corresponding parameters to the function like this. Note: text and html params must be sent because they are required by the function of you are gonna get errors, but they are ignored and the template is sent

// lifecycles.js

module.exports = {
  async afterCreate(event) {
    const { result } = event;
    try {
      await strapi.plugins["email"].services.email.send({
        to: result.email,
        from: "[email protected]", //e.g. single sender verification in SendGrid
        replyTo: "[email protected]",
        subject: "Welcome",
        text: "Bienvenido! " + result.name,
        html: "Bienvenido ! " + result.name,
        TemplateID: 4495580,
        TemplateLanguage: true,
        TemplateErrorDeliver: true,
        Variables: { name: result.name },
      });
    } catch (error) {
      console.log("Error sending welcome email ", error);
    }
  },
};```

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

No branches or pull requests

3 participants