question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with sendTemplatedEmail

See original GitHub issue

Tried triggering email using sendTemplatedEmail with the following codes but encountered Bad Request 400 error, and the weird part is there was no error message returned. Using v0.4.1.

        try {
            await strapi.plugins['email-designer'].services.email.sendTemplatedEmail(
              {
                to: user.email, // required
                from: 'no-reply@xxx.com', // optional if /config/plugins.js -> email.settings.defaultFrom is set
                replyTo: 'no-reply@xxx.com', // optional if /config/plugins.js -> email.settings.defaultReplyTo is set
              },
              {
                templateId: 4, // required - you can get the template id from the admin panel
                subject: 'Welcome'
              },
              {
                // this object must include all variables you're using in your email template
                project_name: 'Test Mailer',
              }
            );

          } catch (err) {
            strapi.log.debug('📺: ', err);
            return ctx.badRequest(null, err);
          }

This is the debug error from Strapi, which is an empty error.

[2021-05-14T07:51:27.462Z] debug �📺:  
[2021-05-14T07:51:27.464Z] debug POST /auth/local/register (11297 ms) 400

The response from API call is empty as well.

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": {},
  "data": {}
}

Sending email using the old API works but flagged as depreciated.

      await strapi.plugins['email-designer'].services.email.send({
        templateId,
        to,
        from,
        replyTo,
        // subject,
        data: userData,
      });

Couldn’t verify whether it’s related to the template_id faced by Sendgrid.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
TasosBakcommented, May 30, 2021

Thank you very much! I will look into it!

1reaction
creazy231commented, May 28, 2021

Hello guys! Where is the following code supposed to be added?

You can use this code everywhere in your custom code. For example: strapi/api/**/controllers/**.js.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot Amazon SES SendTemplatedEmail delivery ...
I'm using the SendTemplatedEmail operation to send messages from my Amazon Simple Email Service (Amazon SES) account.
Read more >
SES.sendTemplatedEmail silently fails when one of ... - GitHub
Hi, I have created a template in SES with four {{variables}} to be interpolated. When I call the SES.sendTemplatedEmail and one of the ......
Read more >
Amazon SES does nothing - Stack Overflow
I'm trying to use the Amazon SES sendTemplatedEmail function. ... Issue sending email from localhost using amazon web services SES.
Read more >
Configuring Send Templated Email Order Module
Configuring Send Templated Email Order Module. When the module runs, a templated email is sent to the client or to a predetermined appropriate...
Read more >
Solved: Re: ACS-Commons "Send Templated Email" process ...
Hi All,. Hope you all are doing well. I'm trying to use ACS-Commons "Send Templated Email" process in my workflow step to send...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found