퍼블릭 클라우드

Amazon SES를 사용하여 이메일 전송 테스트를 수행하는 방법

변군이글루 2021. 9. 15. 10:30
반응형

Amazon Simple Email Service(Amazon SES)를 사용하여 이메일 전송 테스트를 수행하는 방법

1. 이메일 전송 테스트

SES 대시보드에서 이메일 전송

  • Email Addresses 또는 Domains에서 인증된 이메일 주소 또는 도메인을 선택합니다.
  • Send a Test Email 버튼을 클릭합니다.

이메일 전송 세부 정보 입력

  • Email address : 수신자 이메일 주소를 입력합니다.
  • Subject : 이메일 제목을 입력합니다.
  • Body : 이메일 본문을 입력합니다.
  • Format : 텍스트 또는 HTML 형식을 선택합니다.
  • 모든 내용을 입력한 후 "Send Test Email" 버튼을 클릭합니다.

2. AWS CLI를 사용한 이메일 전송

AWS CLI를 통해 이메일을 전송할 수도 있습니다.

AWS CLI 설치 및 구성

AWS CLI를 설치합니다.

AWS CLI를 통한 이메일 전송

이메일을 전송합니다

aws ses send-email \
  --from "verified-email@example.com" \
  --destination "ToAddresses=recipient@example.com" \
  --message "Subject={Data=Test Email,Charset=utf8},Body={Text={Data=This is a test email,Charset=utf8}}"
  • --from : 인증된 이메일 주소를 입력합니다.
  • --destination : 수신자 이메일 주소를 입력합니다.
  • --message : 이메일 제목과 본문을 입력합니다.

3. 프로그래밍 방식으로 이메일 전송

프로그래밍 언어를 사용하여 Amazon SES를 통해 이메일을 전송할 수 있습니다.

Python 및 boto3 설치

Python이 설치되어 있어야 합니다.

boto3 라이브러리를 설치합니다.

pip install boto3

Python 스크립트를 작성하여 이메일 전송

Python 스크립트를 작성합니다.

import boto3
from botocore.exceptions import NoCredentialsError, PartialCredentialsError

# SES 클라이언트 생성
client = boto3.client('ses', region_name='us-east-1')  # 리전을 설정합니다.

# 이메일 전송 함수
def send_email():
    try:
        response = client.send_email(
            Source='verified-email@example.com',
            Destination={
                'ToAddresses': [
                    'recipient@example.com',
                ],
            },
            Message={
                'Subject': {
                    'Data': 'Test Email',
                    'Charset': 'UTF-8'
                },
                'Body': {
                    'Text': {
                        'Data': 'This is a test email sent from Amazon SES using boto3.',
                        'Charset': 'UTF-8'
                    }
                }
            }
        )
        print("Email sent! Message ID:"),
        print(response['MessageId'])
    except (NoCredentialsError, PartialCredentialsError):
        print("Credentials not available")

# 이메일 전송 호출
send_email()

 

Python 코드로 Amazon SES를 사용하여 이메일을 전송할 수 있습니다.

Amazon SES에서 이메일 전송 테스트(시뮬레이션된 시나리오)

  • 전송 성공 : success@simulator.amazonses.com
  • 반송 메일 : bounce@simulator.amazonses.com
  • 자동 응답 : ooto@simulator.amazonses.com
  • 불만 제게 : complaint@simulator.amazonses.com
  • 금지 목록의 받는 사람 주소 : suppressionlist@simulator.amazonses.com

 

참고URL

- AWS Documentation : Amazon SES이란 무엇인가요?

 

728x90
반응형