6

I'm trying to figure out how to send cognito sign-in verification email:

  1. in the user preferred language
  2. in HTML with images (such as the company logo).

For the first one, I found this question and the answer suggests using Lambda triggers with custom attribute for language selection. The solution looks promising and I will definitely give it a try.

For the second one including image in email, I found base64 encoded images in email signatures which suggests two ways:

  1. embed image using data URI within the <img> tag
  2. embed image as attachment.

I tried (1) and it works for Thunderbird email client, but not for Gmail.

Is there a way to send cognito verification email with image?

double-beep
  • 5,031
  • 17
  • 33
  • 41
Bing Ren
  • 1,589
  • 17
  • 26

3 Answers3

6

I see that you are looking to add your company logo in the Cognito sign-in verification email. I recently did the same thing. I tried to use base64 encoded image but the encoded value was pretty big and it's hard to maintain that.

However, the simpler way would be to store the image in online storage and use the image link for img src.

<a href='https://your_company_address.com'><img src="https://s3bucket_folder.s3.amazonaws.com/uploads/your_company_log.png" width= "40%" align= "center"/></a>

Hope it helps.

Vishanth
  • 1,320
  • 3
  • 14
  • 26
  • I guess this is the most practical way so far, although I am concerned that external links / images might be blocked by some email clients. The best solution might be embedding image as attachment but it doesn't seem to be possible at the moment. Thanks for the answer! – Bing Ren Apr 02 '19 at 04:19
1

Cognito supports HTML content(not just an image, but you could have animations and various fonts as well) in the Custom Message body. You could use HTML both in the static custom message text box(In the MFA and Verification section of the Cognito Console), and in the Dynamic Custom Message Lambda Trigger as well. I have tested various HTML content out on my end, and I was able to get them rendered without any hassles.

However, kindly be aware that Cognito has a limitation of 20,000 characters for the E-Mail message.

Use placeholders in the email body. {username} will be replaced by the username/email and {####} will be replaced by the temporary password. A sample E-Mail template can be found in this link.

Simply using the img tag should enable you to have custom images in the Cognito E-Mail.

Arka Mukherjee
  • 2,083
  • 1
  • 13
  • 27
  • Thanks for the answer! I guess using external linked image is the only practical way to do that at the moment. – Bing Ren Apr 02 '19 at 04:20
-1

Here the steps are clearly mentioned on how to include images in my custom verification email templates.

But however, Gmail doesn't support displaying embedded images.

Vishanth
  • 1,320
  • 3
  • 14
  • 26
  • Thanks for the link. However that link is for the custom verification email for SES. I'm searching for something working for AWS Cognito sign-in verification email. – Bing Ren Jan 31 '19 at 00:52