-
Sign up for Amazon Web Services: http://aws.amazon.com
-
Enable "Simple Email Service": http://aws.amazon.com/ses/
-
Install Boto in your Web2py "site-packages" folder: https://github.com/boto/boto
-
Obtain your Amazon AWS-KEY and AWS-SECRET-KEY: https://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&action=access-key
-
Before you get "production" access to Amazon's mail servers, you have to pre-register every sender and recipient email address you want to use (up to 100). This is OK for development and testing but of course would not work in production. To register an email address, execute the following code, replacing AWS-KEY and AWS-SECRET-KEY with your own keys and myemail@address.com with the email address you want to register:
from boto.ses.connection import SESConnection def verify_email_address(): conn = SESConnection('<AWS-KEY>', '<AWS-SECRET-KEY>') m = conn.verify_email_address('myemail@address.com')
-
Now you are ready to send an email:
from boto.ses.connection import SESConnection aws_key = '<AWS-KEY>' aws_secret_key = '<AWS-SECRET-KEY>' def send_ses(params): conn = SESConnection(aws_key, aws_secret_key) return conn.send_email(source='myemail@address.com', subject='Subject', body='Body.', to_addresses='recipient@email.com', cc_addresses=None, bcc_addresses=None, format='text', reply_addresses=None, return_path=None)
Comments (0)