Skip to content

Instantly share code, notes, and snippets.

@LeoHeo
Last active May 13, 2018 08:59
Show Gist options
  • Save LeoHeo/04a0eda3daf62fe563023ca56436e7d4 to your computer and use it in GitHub Desktop.
Save LeoHeo/04a0eda3daf62fe563023ca56436e7d4 to your computer and use it in GitHub Desktop.
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
// AWS SDK v2
compile group: 'software.amazon.awssdk', name: 'ses', version: "${awsSdkSesVersion}"
compile group: 'net.minidev', name: 'json-smart', version: "${minidevVersion}"
package com.collect.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import software.amazon.awssdk.core.auth.AwsCredentials;
import software.amazon.awssdk.core.regions.Region;
import software.amazon.awssdk.services.ses.SESAsyncClient;
/**
* @author Heo, Jin Han
* @since 2018-05-02
*/
@Configuration
public class AwsSesConfig {
@Value("${AWS_ACCESS_KEY_ID}")
private String AWS_ACCESS_KEY_ID;
@Value("${AWS_SECRET_KEY}")
private String AWS_SECRET_KEY;
@Bean
public SESAsyncClient sesAsyncClient() {
return SESAsyncClient.builder()
.credentialsProvider(() -> AwsCredentials.create(AWS_ACCESS_KEY_ID, AWS_SECRET_KEY))
.region(Region.US_WEST_2)
.build();
}
}
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/xhtml">
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1 th:text="${test}"></h1>
</body>
</html>
/**
* @author Heo, Jin Han
* @since 2018-04-06
*/
@AllArgsConstructor
@Service
public class UserService {
private final AwsSesUtils awsSesUtils;
public void sendEmail() {
final String SUBJECT = "Amazon SES test (AWS SDK for Java)";
Context context = new Context();
context.setVariable("test", "test1111");
awsSesUtils.singleEmailRequest("[email protected]", SUBJECT, "test", context);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment