简体   繁体   中英

Best way to send e-mail programmatically from docker container (Spring Boot app) hosted Amazon AWS ECS Cluster?

I was wondering if anyone could advise the "best" (I know that's subjective, but meaning "best" as in least amount of work/steps) to trigger sending an E-mail from Amazon AWS. The Message body with contain dynamic variables/data from my App (Spring boot) so I will have to wire that in somehow, and it should be triggered from within my Application whenever it finishes processing some data, since my app reads .CSV data.

  1. I cannot use JavaMail/Jakarta to send e-mail from within app as all Containers I have have blocked ports
  2. Preferably using some type of AWS service since I'm already hosting this app on AWS ECS cluster

I would like to do it programmatically: 在此处输入图片说明

AWS provides Amazon Simple Email Service (SES) which is:

is an email platform that provides an easy , cost-effective way for you to send and receive email using your own email addresses and domains.

To use that, you would add SES permissions to your ECS tasks role . This way, you don't need to hard-code any AWS credentials into your application, as they will be automatically obtained by AWS SDK when interacting with SES.

AWS also provides AWS SDK for java . Using the SDK you can send emails using SES as shown in the example Send an email using the AWS SDK for Java .

If you want to send an email from a Spring Boot app, then use the Simple Email Service Java V2 API. There is an AWS Java V2 tutorial that shows how to build a Spring BOOT app that uses various AWS Services to analyze photos located in an Amazon S3 bucket. This app uses the SES Java V2 API to send a report that contains the details of the Amazon Rekognition service that analyzes the photos.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM