Couldn't receive email notification using SES in Glue script

0

I have added and verified my email in SES. However, when I use this service in Glue script, no email notification receives. Refer to screenshot.

Enter image description here

Below is my Glue script.

import boto3
from botocore.exceptions import ClientError

def send_email(subject, body, recipient):
    ses_client = boto3.client('ses', region_name='us-west-2')
    sender = 'rshah@astotek.com'

    message = {
        'Subject': {
            'Data': subject
        },
        'Body': {
            'Text': {
                'Data': body
            }
        }
    }

    try:
        response = ses_client.send_email(
            Source=sender,
            Destination={
                'ToAddresses': [recipient]
            },
            Message=message
        )
        print("Email sent! Message ID:", response['MessageId'])
    except ClientError as e:
        print("Error sending email:", e)

send_email("Test Subject", "Hello, this is a test email.", "rshah@astotek.com")

Nothing in my inbox or spam/junk folder. Is anything wrong with script or am I missing something? No error shows up.

已提问 3 个月前125 查看次数
1 回答
0

You might have an error that you printing to the "Output" log, maybe don't catch it so you are immediately aware.
If the call works, there is no difference calling boto3 inside Glue on anywhere else.

When it doesn't error or finish as you say, it's very likely that the jobs runs inside a VPC and doesn't have access to the email endpoint.
If you wait long enough (10 minutes, it should timeout and tell you which url is trying to access).

profile pictureAWS
专家
已回答 3 个月前
  • The problem is, the job runs infinitely and doesn't print any log. I had to stop the job. What could be problem?

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则