Welcome email from lambda not getting sent

0

I have created a stack which has lambada function for registration of user. Now when use register using our page this lambada function gets trigged and it has functionality to send welcome email to registered user. Now we have verified our email id in identity management portal. Now when we register using our email id, this function of sending welcome email gets triggered but we do not receive email in our inbox.

Also, it has field called senderEmailId. But in our case, it comes as empty or null. We tried even hardcoding this email id but still we are not able to receive the email. So have couple of questions as below.

  1. Where we have to mention that senderEmailId or from where lambada function will be able to pick it up? do we need to update or put it somewhere in any config or what?
  2. Whether Welcome Email logic even work or how it is? and if it is not Production ready then why does it come in any new lambada function which gets created for any new stack?
2 Answers
0

It seems you're experiencing issues with sending welcome emails from your Lambda function using Amazon SES (Simple Email Service). Let's address your questions:

  1. Regarding the senderEmailId: The sender email address should be specified in your Lambda function code. It's not automatically populated, so you need to explicitly set it. You can either hardcode it in your function or store it in environment variables or AWS Systems Manager Parameter Store and retrieve it in your code. Make sure the email address you're using as the sender is verified in Amazon SES.

  2. Concerning the welcome email functionality: The welcome email functionality should work if set up correctly. It's not that it's not production-ready, but rather it requires proper configuration. Here are some things to check:

    • Ensure your AWS account is out of the SES sandbox. If you're in the sandbox, you can only send emails to verified email addresses.
    • Verify that both the sender and recipient email addresses are verified in SES if you're in the sandbox.
    • Check your Lambda function's IAM role has the necessary permissions to send emails via SES.
    • Implement proper error handling in your Lambda function and check CloudWatch logs for any errors.
    • Make sure your Lambda function is actually being triggered when a user registers.

If you're still not receiving emails, consider the following:

  • Check your spam or junk folder.
  • There might be a delay in email delivery; wait a few minutes.
  • Review the SES console for any error messages or failed delivery notifications.
  • Try using the SES mailbox simulator (e.g., success@simulator.amazonses.com) to test if the sending process works correctly.

If the problem persists after checking these points, you may need to review your Lambda function code for any logical errors in the email sending process, or contact AWS support for further assistance.

Remember, the welcome email functionality is included in new Lambda functions as a common use case, but it still requires proper setup and configuration to work correctly.

Sources
Why Lambda function does not send email | AWS re:Post
Send Test Email | AWS re:Post

profile picture
answered 15 days ago
0

Hi,

It seems you're experiencing issues with sending welcome emails from your Lambda function using Amazon SES (Simple Email Service). Here's how to address your concerns:

  1. SenderEmailId:

    • Specify this in your Lambda function code.
    • You can hardcode it, use environment variables, or retrieve it from AWS Systems Manager Parameter Store.
    • Ensure the sender email is verified in Amazon SES.
  2. Welcome Email Functionality:

    • This should work if set up correctly.
    • It's included in new Lambda functions as a common use case but requires proper configuration.

Key points to check:

  1. SES Sandbox:

    • New AWS accounts start in SES sandbox mode.
    • In sandbox, you can only send to verified email addresses.
    • Both sender and recipient emails must be verified.
    • Daily sending quotas are limited.
  2. Verify Permissions:

    • Ensure your Lambda's IAM role has permissions to send emails via SES.
  3. Check Configuration:

    • Verify your Lambda is actually triggered on user registration.
    • Implement error handling and check CloudWatch logs for issues.
  4. Troubleshooting:

    • Check spam/junk folders.
    • There might be email delivery delays.
    • Review SES console for error messages or failed deliveries.
    • Use SES mailbox simulator (e.g., success@simulator.amazonses.com) for testing.

Here's a basic Lambda code structure for sending emails:

import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses";

const ses = new SESClient({ region: "YOUR_REGION" });
const SENDER_EMAIL = "your-verified@email.com"; // Set this

export const handler = async (event) => {
  const recipientEmail = event.email; // Assuming email is passed in the event

  const params = {
    Source: SENDER_EMAIL,
    Destination: { ToAddresses: [recipientEmail] },
    Message: {
      Subject: { Data: "Welcome!" },
      Body: { Text: { Data: "Thank you for registering." } }
    }
  };

  try {
    const command = new SendEmailCommand(params);
    await ses.send(command);
    console.log("Email sent successfully");
  } catch (error) {
    console.error("Error sending email:", error);
    throw error;
  }
};

To move out of SES sandbox:

  1. Go to SES console
  2. Request production access
  3. Provide business justification and expected sending volume

For more information, see:

If issues persist after these checks, review your Lambda code for logical errors or contact AWS support.

AWS
answered 15 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions