2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Amazon SESを使ってPythonからメールを送信する

Last updated at Posted at 2018-11-28

以下を参考にAmazon SESを使ってPythonからメールを送信する
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ses.html

関数を定義

def send_email(source, to, subject, body):
    client = boto3.client('ses')
    response = client.send_email(
    Destination={
        'ToAddresses': [
            to
        ],
    },
    Message={
        'Body': {
            'Text': {
                'Charset': 'UTF-8',
                'Data': body,
            },
        },
        'Subject': {
            'Charset': 'UTF-8',
            'Data': subject,
        },
    },
    Source=source
    )
    return response

実際に送信する

    source = '[送信元]'
    to = '[送信先]'
    subject = '[タイトル]'
    body = '[本文]'
    r = send_email(source, to, title, body)
    print(r)
2
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?