Created
February 13, 2017 22:13
-
-
Save gogarufi/316eab098d745fbaa0722725451cffe2 to your computer and use it in GitHub Desktop.
AWS Lambda class with a public handler method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gogarufi.lambda.ses; | |
import com.amazonaws.services.lambda.runtime.Context; | |
import com.amazonaws.services.lambda.runtime.LambdaLogger; | |
import java.util.Map; | |
public class EmailSender { | |
public void send(Context context) { | |
LambdaLogger logger = context.getLogger(); | |
Map<String, String> env = System.getenv(); | |
String from = env.get("FROM"); | |
String to = env.get("TO"); | |
String body = "This email was sent through Amazon SES"; | |
String title = "Amazon SES Test"; | |
logger.log("Sending an email ... \n"); | |
try { | |
Integer httpStatusCode = EmailService.send(from, to, body, title); | |
logger.log("Response HTTP status code: " + httpStatusCode + "\n"); | |
} catch (EmailServiceException e) { | |
logger.log("Can't send the email due to an exception: " + e + "\n"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment