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.

gefragt vor 3 Monaten125 Aufrufe
1 Antwort
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
EXPERTE
beantwortet vor 3 Monaten
  • The problem is, the job runs infinitely and doesn't print any log. I had to stop the job. What could be problem?

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen