-
-
안녕하세요? 오늘은, 아마존 이메일 서비스인 AWS SES ( Amazon Simple Email Service ) 에 대해서 알아보도록 하겠습니다.
AWS SES 란??
: Amazon Simple Email Service 의 약자로,
사용자의 이메일 주소와 도메인을 사용해 이메일을 보내고 받기 위한,
경제적이고 손쉬운 방법을 제공하는 이메일 플랫폼 이라고 설명하고 있다.
https://docs.aws.amazon.com/ko_kr/ses/latest/DeveloperGuide/Welcome.html
Amazon SES 클래식란 무엇입니까? - Amazon Simple Email Service
이 페이지에 작업이 필요하다는 점을 알려 주셔서 감사합니다. 실망시켜 드려 죄송합니다. 잠깐 시간을 내어 설명서를 향상시킬 수 있는 방법에 대해 말씀해 주십시오.
docs.aws.amazon.com
2탄에서는 Java Spring + 메이븐 프로젝트를 통해 구현하는 방법을 알아보도록 하겠습니다.
※ 사전 필수 작업은 1탄 참조 (현재 작업중 입니다.)
1. 메이븐 디펜던시 추가를 해줍니다. (pom.xml)
<!-- AWS -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.11.927</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.927</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-ses</artifactId>
<version>1.11.927</version>
</dependency>
2. SenderDto 생성을 해줍니다.
@Getter
public class SenderDto {
private String from;
private String to;
private String subject;
private String content;
@Builder
public SenderDto(String from, String to, String subject, String content) {
this.from = from;
this.to = to;
this.subject = subject;
this.content = content;
}
public SendEmailRequest toSendRequestDto() {
Destination destination = new Destination().withToAddresses(this.to);
Message message = new Message()
.withSubject(createContent(this.subject))
.withBody(new Body().withHtml(createContent(this.content)));
return new SendEmailRequest()
.withSource(this.from)
.withDestination(destination).withMessage(message);
}
private Content createContent(String text) {
return new Content().withCharset("UTF-8")
.withData(text);
}
}
3. Sender 생성을 해줍니다.
@Slf4j
public class Sender {
public SendEmailResult send(SenderDto senderDto) {
SendEmailResult result = null;
try {
BasicAWSCredentials credentials = new BasicAWSCredentials("액세스키",
"시크릿액세스키");
AmazonSimpleEmailService client = AmazonSimpleEmailServiceClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withRegion("리전주소").build();
result = client.sendEmail(senderDto.toSendRequestDto());
} catch (Exception ex) {
log.error("The email was not sent.");
log.error("Error message: " + ex.getMessage());
throw new AmazonClientException(ex.getMessage(), ex);
}
return result;
}
}
4. test 코드 작성을 합니다.
/**
* AWS SES 메일 발송 처리입니다.
* @param String to, String subject, String content
* @return SendEmailResult
* @throws
*/
public SendEmailResult sendEmail(String to, String subject, String content) {
SendEmailResult result = null;
Sender sender = new Sender();
SenderDto dto = new SenderDto("AWS SES 등록 이메일주소", to, subject, content);
result = sender.send(dto);
return result;
}
※ 참조 사이트
메이븐 :https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk/1.11.9276
소스 참조 : https://jojoldu.tistory.com/246
SES 가이드 : https://docs.aws.amazon.com/ko_kr/ses/latest/DeveloperGuide/Welcome.html
전송할당량 : https://docs.aws.amazon.com/ko_kr/ses/latest/DeveloperGuide/manage-sending-quotas.html
Response : https://docs.aws.amazon.com/ko_kr/ses/latest/DeveloperGuide/using-ses-api-responses.html
오늘은, 아마존 이메일 서비스인 AWS SES에 대해서 알아보았습니다.
그럼 오늘도 즐거운 하루 되시길 바라겠습니다.
'프로그래밍 > Back-end' 카테고리의 다른 글
Java에서 정규식(Regex) 사용법과 메타문자 소개 (0) | 2024.11.15 |
---|---|
자바에서 서버의 호스트명을 가져오는 방법 (0) | 2024.11.13 |
자바에서 경로 다루기: File, Request, Session을 활용한 경로 처리 방법 (0) | 2024.11.12 |
자바 AWS SNS ( Amazon Simple Notification Service ) ! 아마존 문자 서비스 구현 ! (0) | 2024.10.25 |
JPA 쿼리 JPQL 벌크 연산 (0) | 2024.10.24 |
JPA 쿼리 패치 조인 JPQL FETCH JOIN (0) | 2024.10.24 |
JPA JPQL 경로 표현식 (0) | 2024.10.23 |
JPA JPQL 타입 표현식과 기타식 그리고 조건식과 기본 함수 (0) | 2024.10.18 |