Amazon SES Issue - Difficulty Sending Emails from Business Mail

0

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 .

1 Answer
0

Hi Andre,

There are 2 ways verify the email in SES. 1st is to verify each and every email(Including business) Every email gets a mail to confirm the identity and once confirmed, you can use that to send mails.

2nd is to verify the domain directly ex: mycompany.it. with this approach, you can use any email from the domain @mycompany.it. This approach needs devops and other team to provide and configure the doamin certificate in SES.

Another way with 2nd approach can be, assuming your application has stored it's domain certificate in AWS certification manager. Let's say your application is hosted with abc.com domain and SSL is present in AWS certificate manager then you can this certificate to verify the abc.com domain in SES and can send email with the address zzz@abc.com or yyy@abc.com and so on.

Hope it helped!

answered 5 months ago
  • 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

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions