Skip to content
This repository has been archived by the owner on Feb 24, 2018. It is now read-only.

Get verification code in lambda for external mail service #623

Open
jkettmann opened this issue Dec 13, 2017 · 3 comments
Open

Get verification code in lambda for external mail service #623

jkettmann opened this issue Dec 13, 2017 · 3 comments

Comments

@jkettmann
Copy link

I'm using SendGrid as an external email service to send custom transactional emails. What I would like to do is to send a custom email verification including the code via SendGrid. I use auto confirmation, so to send the verification code I need to use.

cognitoUser.getAttributeVerificationCode('email' ...

I have a trigger on CustomMessage. My lambda is called and everything is working fine except I can't get the verification code to deliver it to SendGrid and render it in my email template. I could only find codeParameter which is {####}.

So how can I get the verification code to send it to external services?

This is my lambda.

'use strict';
const sgMail = require('@sendgrid/mail');

sgMail.setApiKey(process.env.SEND_GRID_API_KEY);
sgMail.setSubstitutionWrappers('{{', '}}');

module.exports.sendMail = (event, context, callback) => {
  console.log(event);

  if (event.request.userAttributes.email) {
    const msg = {
      template_id: 'someTemplateId',
      to: event.request.userAttributes.email,
      from: fromEmail,
      substitutions: {
        verificationCode: event.request.codeParameter,
      },
    };
    sgMail.send(msg)
      .then(() => context.done(null, event))
      .catch((error) => {
        console.log("sgMail.send failed",  error);
        context.done(null, event);
      });
  } else {
      console.log("Failed");
      context.done(null, event);
  }
};
@jkettmann
Copy link
Author

Could anybody help with this? We are moving to production and I still couldn't find a real solution for this. I think I could set custom HTML code inside the Lambda which would be sent out via AWS, but that's not really what I'm looking for...

Any solution for sending the verification code via a third party service?

@itrestian
Copy link
Contributor

This is not possible at this point. We do have a roadmap item to let users configure other providers. However, I cannot comment on the availability.

@itsTeknas
Copy link

I'm facing the same problem. I can't even get my SES Email limit increased due to some silly bounce and complaints compliance which i don't understand.

All i want to do is send the verification code form my own domain email id.

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

No branches or pull requests

3 participants