LoginSignup
2
3

More than 5 years have passed since last update.

Amazon SESで自動メール送信する

Last updated at Posted at 2017-08-08

仕事でメール送信自動化のためにSESを使用使ったのでメモ

メールアドレスの認証

使用するメールアドレスを認証する必要があります
作成したばかりのユーザーは SES サンドボックスの中にいるため、送信元、送信先ともに認証が必要です。
後述の方法でサンドボックスの外へ移動すると、verify していない送信先へも送れるようになります。

Identity Management -> Email Addresses -> Verify New Email Address で使用するメールアドレスに認証メールを送る。

Screen Shot 2017-08-08 at 16.19.50.png

メール内のリンクをクリックして、 Email の右の Status が verified になったのを確認する。

Sandbox制限の解除

コンソールにログインしてサポートセンターからSES送信制限解除依頼を出します。
1~2日で解除されます。

Screen Shot 2017-08-08 at 16.21.44.png

参考: http://docs.aws.amazon.com/ja_jp/ses/latest/DeveloperGuide/request-production-access.html

送信テスト


import boto3

client = boto3.client('ses', region_name='us-east-1')
response = client.send_email(
    Source='sender@example.com',
    Destination={
        'ToAddresses': ['receiver@example.com']
    },
    Message={
        'Subject': {
            'Data': 'hello',
        },
        'Body': {
            'Text': {
                'Data': 'hello ses.',
            }
        }
    })
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3