Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8837393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:42:44+00:00 2026-06-14T09:42:44+00:00

I am using Python and smtplib to send email via Amazon SES. How do

  • 0

I am using Python and smtplib to send email via Amazon SES. How do I catch specific sending errors?

For example, Amazon SES may tell me “this address is blacklisted” or “you’ve exceeded your rate” or “you’ve exceeded your volume quota”, and I want to act on those messages.

I have a snippet which catches blacklisting (I think), as follows. I don’t really know how to debug these things, since the exceptions will only show up in heavy-duty environments, and if I trigger the exceptions then I’m worried Amazon will ding my quota.

try:
    msg = EmailMultiAlternatives(subject, plain, from_address, [to_address])
    msg.attach_alternative(html, "text/html")
    msg.send()
except smtplib.SMTPResponseException as e:
    error_code,error_msg = e.smtp_code, e.smtp_error
    if error_code==554 and error_msg=='Message rejected: Address blacklisted.':
        # do appropriate action for blacklisting
    else:
        # do appropriate action for throttling
    else:
        # log any other SMTP exceptions
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:42:47+00:00Added an answer on June 14, 2026 at 9:42 am

    You can use the Amazon SES Mailbox Simulator to generate a blacklist error.

    Send an email to blacklist@simulator.amazonses.com to verify if your application handles the resulting error properly. Your bounce statistics will not be impacted if you use Mailbox Simulator addresses. You can run these tests whether your Amazon SES account is in Sandbox or Production mode.

    The Mailbox Simulator does not currently let you test for throttling or quota exceptions. However, your exception handling code should be sufficient to handle those exceptions. I recommend you check for the exception string using find() in order to accommodate any additions to the error message.

    if error_code == 554 and error_msg.find('Address blacklisted') >= 0:
        # handle blacklisting
    else: 
        ...
    

    For reference, here are some of the SMTP responses that you can check for:

    • Blacklisting is “554 Message rejected: Address blacklisted”
    • Unverified Address is “554 Message rejected: Email address is not verified.”
    • Exceeded Send Rate is “454 Throttling failure: Maximum sending rate exceeded.”
    • Exceeded Quota is “454 Throttling failure: Daily message quota exceeded.”
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following script for sending mails using python import smtplib from email.mime.multipart
I want to send an email with an attachment using the following code (Python
I have a program to send mail using python smtplib. I have the mail
I want to write a program that sends email using Python's smtplib . I
I am using python smtplib and xoauth and I am trying to send an
I'm trying to send an email with an excel file attached using smtplib in
I am trying to send an email using the Python email client. I have
Possible Duplicate: Specify a sender when sending mail with Python (smtplib) I'm using smtplib
I'm using smtplib to send emails through Python, everything's well and works fine, but
I am successfully able to send email using the smtplib module. But when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.