Skip to content

Commit

Permalink
* Added a method for sending emails via AWS SES.
Browse files Browse the repository at this point in the history
* Improved the EmailSender code.
  • Loading branch information
vnandwana committed Dec 20, 2023
1 parent 3c1cd7a commit 61cef03
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<check.fail-dependency>false</check.fail-dependency>
<check.fail-spotbugs>true</check.fail-spotbugs>
<check.spotbugs-exclude-filter-file>spotbugs-exclude.xml</check.spotbugs-exclude-filter-file>
<commons-logging.version>1.3.0</commons-logging.version>
<maven.javadoc.failOnError>false</maven.javadoc.failOnError>
<osgi.export>org.killbill.billing.plugin.notification.api,org.killbill.billing.plugin.notification.generator.*</osgi.export>
<osgi.private>org.killbill.billing.plugin.notification.*</osgi.private>
Expand Down Expand Up @@ -91,6 +92,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons-logging.version}</version>
</dependency>
<dependency>
<groupId>io.zonky.test</groupId>
<artifactId>embedded-postgres</artifactId>
Expand All @@ -113,7 +119,6 @@
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class EmailSender {
private static final String EMAIL_NOTIFICATION_VIA_SES = "org.killbill.email.notification.via.ses";
private static final String AWS_REGION = "org.killbill.aws.region";

private static final String DEFAULT_AWS_REGION = "us-east-1";
private static final String DEFAULT_AWS_REGION = "US_EAST_1";

private final boolean useSmtpAuth;
private final int useSmtpPort;
Expand Down Expand Up @@ -216,7 +216,7 @@ private void sendEmailViaSES(final List<String> to, final List<String> cc, final
return;
}

final Regions region = Regions.valueOf(awsRegion);
final Regions region = Regions.valueOf(awsRegion.toUpperCase());

final AmazonSimpleEmailService client = AmazonSimpleEmailServiceClientBuilder.standard()
.withRegion(region)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ public class TestEmailSender {
private static final String TEST_SMTP_PWD = "bar";
private static final String TEST_SMTP_FROM = "caramel@mou.com";

private static final String AWS_REGION = "us-east-1";


@Test(enabled = false)
public void foo() throws IOException, EmailException, EmailNotificationException {
EmailSender sender = new EmailSender(TEST_SMTP_SERVER_NAME, TEST_SMPT_SERVER_PORT, TEST_SMTP_USER, TEST_SMTP_PWD, TEST_SMTP_FROM, true, false, false);
final EmailSender sender = new EmailSender(TEST_SMTP_SERVER_NAME, TEST_SMPT_SERVER_PORT, TEST_SMTP_USER,
TEST_SMTP_PWD, TEST_SMTP_FROM, true, false,
false, AWS_REGION, false);
final String to = "something_that_works@gmail.com";
sender.sendPlainTextEmail(ImmutableList.of(to), ImmutableList.<String>of(), "coucou", "body", Mockito.mock(SmtpProperties.class));
}
Expand Down

0 comments on commit 61cef03

Please sign in to comment.