i wrote this code to test the send of some emails :
import boto3
aws_region = 'eu-west-1'
sender_email = 'personal_email@gmail.com' # it works!
reciver_email = 'personal_email@gmail.com'
#sender_email = 'personal_email@gmail.com' # it works!
#reciver_email = 'company_email@mycompany.it'
#sender_email = 'company_email@mycompany.it' # doesnt works i get and email with sub "FAILURE"
#reciver_email = 'personal_email@gmail.com'
#sender_email = 'company_email@mycompany.it' # doesnt works i get and email with sub "UNDELIVERABLE"
#reciver_email = 'company_email@mycompany.it'
subject = """ Test invio """
body_html = f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Error ! </title>
</head>
<body>
il sender e' {sender_email} <br>
il reciver e' {reciver_email}
</body>
</html>
"""
ses_client = boto3.client('ses', region_name=aws_region)
message = {
'Subject': {'Data': subject},
'Body':{'Html':{'Data':body_html}},
}
try:
response = ses_client.send_email(
Source=sender_email,
Destination={'ToAddresses':[reciver_email]},
Message = message
)
print("SEND MAIL test COMPLETED CORRECTLY! MESSAGE ID: ", response['MessageId'])
print('\n')
except ClientError as err:
print("ERROR WHILE SENDING THE MAIL! ", err)
print('\n')
this is just a template and it works only when i use my personal email gmail , when i try to use my company_email it doesnt work, the mails that is use for this test were properly register inside SES.
looking on the web i can fix this issue i have To set up the identity on SES in a specific way and then configure the DKIM, DMARC, and SPF keys is required. but i cant do this because some rules of the company i dont know ... any ideas?
i execute this inside a jupiter notebook .
thanks for your answer sir, but later we resolve this in another way, so we create a dedicated mail : mydedicatedmail@mycompany.com, this email was registered inside ses AND also this email must be registered inside the ticket system of the company some kind of white list , the point is to activate automatic forwarding so that when a message is sent to that dedicated email address it can be forwarded to the company ticket system. in this way you can only use the SES service, without using other services