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.

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?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인