What would be the fastest way to send emails to amazon SES?
<p>I want to send emails, via python, to amazon SES.</p>

<p>I'd like to reach a send rate of about 10 mails per second (actually, twice that would be ideal).</p>

<p>What I found is that if I use the python <code>smtplib</code> library to connect directly, things are really slow. Here's a graph generated with pycallgraph of what happens when I use this code</p>

<pre><code>def login_to_amazon(port=587, secure=True, options=(25, 465, 587)):
    s1 = smtplib.SMTP('email-smtp.us-east-1.amazonaws.com', port)
    if secure:
        s1.starttls()
    s1.login('aws_key', 'aws_secret')
    return s1

def send_multiple_emails(msg, number, port=587):
    s1 = login_to_amazon(port)
    for _ in range(number):
        s1.sendmail('address@provider.com', 'address@provider.com', str(msg))

# I send 5 mails here
send_multiple_emails('about 100 byte message', number=5)
</code></pre>

<p><strong>Bottom line: It takes 4.5 seconds to send the 5 emails.</strong>
<a href="https://i.stack.imgur.com/wc2GQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wc2GQ.png" alt="sending 5 emails through SMTH to amazon SES"></a></p>

<p>Then I tried the boto interface:</p>

<pre><code>from boto import ses
c1 = ses.connect_to_region('us-east-1', aws_access_key_id='public_key', aws_secret_key='secret')

def boto_send_mail(nonce=None):
    if nonce is None:
        nonce = str(datetime.now())
    return c1.send_email(source, subject='testing {}'.format(str(nonce)), body=str(nonce), to_addresses=source)
</code></pre>

<p>Now if I profile calling <code>boto_send_mail</code> 5 times, it takes 2 seconds to send the 5 emails.
<a href="https://i.stack.imgur.com/UxoZl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UxoZl.jpg" alt="enter image description here"></a> </p>

<p>At the moment, I can only send 200 emails per day, and 1 email per second, though if I just send spikes of 5 mails, it doesn't block me, so this is all the analysis I can do.</p>

<p>Does anyone do this in a better way? I need to be at least 2 times faster than I currently am.</p>

<p>Should I use multiple processes/ threads/ asyncio, the AWS SES REST API?</p>

<p>Any advice would be helpful</p>