psudo
psudo

Reputation: 1558

Disable default email sending in AWS Cognito

I'm using AWS Cognito for authentication in my next js app. And I'm using aws-amplify npm package to signup/signin the user.

import {
  Auth
} from "aws-amplify"
import {
  SendTemplatedEmailCommand
} from "@aws-sdk/client-ses"
const handleRegister = async() => {

  try {
    await Auth.signUp({
      username: formik.values.email,
      password: formik.values.password,
    })
    //send email with aws sdk v3
    const emailBody = new SendTemplatedEmailCommand({
      Destination: {
        ToAddresses: ["[email protected]"]
      },
      TemplateData: JSON.stringify({
        data: emailData
      }),
      Source: "[email protected]",
      Template: "welcome",
    })
    await client.send(emailBody)
    formik.resetForm()
    notification.success({
      message: "User registered in AWS Congito"
    })
  } catch (e) {
    notification.error({
      message: e.message
    })
  }
}

I've configured to use AWS SES for sending email (email also verified) in messaging tab.

enter image description here

When I register new user, I get email from AWS SES configured email. But AWS Cognito is also sending its default email with content.

Please click the link below to verify your email address. {##Verify Email##}

I want email from AWS SES configured email only not default email from Cognito.

How do i disable sending default email from Cognito ?

The new AWS Console UI is clean but confusing at the same time.

Upvotes: 1

Views: 1056

Answers (2)

Kenzo
Kenzo

Reputation: 356

Was running into the same problem. The issue is that this cannot be changed once the user pool in Cognito has been configured (and AWS makes no mention of this in the interface after creation), so the solution is to make a new user pool, and under Attribute verification and user account confirmation in Step 3, you have to select Don’t automatically send messages.

enter image description here

Upvotes: 0

radof
radof

Reputation: 611

How about when creating userpool just disabling :

Allow Cognito to automatically send messages to verify and confirm - Recommended

Upvotes: 0

Related Questions