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 réponse
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
EXPERT
répondu il y a 3 mois
  • The problem is, the job runs infinitely and doesn't print any log. I had to stop the job. What could be problem?

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions