List of usage examples for com.amazonaws.services.simpleemail AmazonSimpleEmailServiceClient AmazonSimpleEmailServiceClient
AmazonSimpleEmailServiceClient(AwsSyncClientParams clientParams)
From source file:com.erudika.para.email.AWSEmailer.java
License:Apache License
/** * No-args constructor./*from w w w . j a v a2s. c om*/ */ public AWSEmailer() { sesclient = new AmazonSimpleEmailServiceClient( new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY)); }
From source file:com.espressologic.aws.sqs.AmazonEmailService.java
License:Open Source License
/** * send email using credentials and region * * @param request//from ww w. j a v a 2 s . co m * @throws Exception */ public static void sendEmalRequest(SendEmailRequest request) throws Exception { try { System.out.println("Attempting to send an email through Amazon SES by using the AWS SDK for Java..."); /* * The ProfileCredentialsProvider will return your [default] * credential profile by reading from the credentials file located at * (~/.aws/credentials). * * TransferManager manages a pool of threads, so we create a * single instance and share it throughout our application. */ createAWSCredentials(); // Instantiate an Amazon SES client, which will make the service call with the supplied AWS credentials. AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(credentials); // Choose the AWS region of the Amazon SES endpoint you want to connect to. Note that your production // access status, sending limits, and Amazon SES identity-related settings are specific to a given // AWS region, so be sure to select an AWS region in which you set up Amazon SES. Here, we are using // the US East (N. Virginia) region. Examples of other regions that Amazon SES supports are US_WEST_2 // and EU_WEST_1. For a complete list, see http://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html Region REGION = Region.getRegion(getMyRegion()); client.setRegion(REGION); // Send the email. client.sendEmail(request); System.out.println("Email sent!"); } catch (Exception ex) { System.out.println("The email was not sent."); System.out.println("Error message: " + ex.getMessage()); throw ex; } }
From source file:com.hiveTown.util.AmazonSESUtil.java
License:Open Source License
private AmazonSimpleEmailServiceClient getClient() { BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); // Instantiate an Amazon SES client, which will make the service call with the supplied AWS credentials. AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(credentials); Region REGION = Region.getRegion(Regions.US_WEST_2); client.setRegion(REGION);/*from w ww . j a v a 2s . c om*/ return client; }
From source file:com.irurueta.server.commons.email.AWSMailSender.java
License:Apache License
/** * Prepares client by setting proper credentials. *//* w w w . j ava2 s . c om*/ private synchronized void prepareClient() { if (mClient == null) { //instantiate new client if needed if (areValidCredentials()) { mClient = new AmazonSimpleEmailServiceClient( new BasicAWSCredentials(mCredentials.getAccessKey(), mCredentials.getSecretKey())); } else { //disabling mail sending mEnabled = false; Logger.getLogger(AWSMailSender.class.getName()).log(Level.INFO, "AWS Email Sender disabled. " + "Invalid credentials"); } } }
From source file:com.oneops.antenna.senders.aws.EmailService.java
License:Apache License
/** * Inits the.//from w w w.jav a 2 s .co m */ public void init() { if (this.awsAccessKey == null) { this.awsAccessKey = System.getenv("AWS_ACCESS_KEY"); if (this.awsAccessKey == null) { this.awsAccessKey = System.getProperty("com.oneops.aws.accesskey"); } } if (this.awsSecretKey == null) { this.awsSecretKey = System.getenv("AWS_SECRET_KEY"); if (this.awsSecretKey == null) { this.awsSecretKey = System.getProperty("com.oneops.aws.secretkey"); } } emailClient = new AmazonSimpleEmailServiceClient(new BasicAWSCredentials(awsAccessKey, awsSecretKey)); }
From source file:com.prd.AmazonSESSample.java
License:Open Source License
public static void main(String[] args) throws IOException { // Construct an object to contain the recipient address. Destination destination = new Destination().withToAddresses(new String[] { TO }); // Create the subject and body of the message. Content subject = new Content().withData(SUBJECT); Content textBody = new Content().withData(BODY); Body body = new Body().withText(textBody); // Create a message with the specified subject and body. Message message = new Message().withSubject(subject).withBody(body); // Assemble the email. SendEmailRequest request = new SendEmailRequest().withSource(FROM).withDestination(destination) .withMessage(message);//from ww w. ja va 2s. c o m try { System.out.println("Attempting to send an email through Amazon SES by using the AWS SDK for Java..."); /* * The ProfileCredentialsProvider will return your [default] * credential profile by reading from the credentials file located at * (/Users/prabhjitsingh/.aws/credentials). * * TransferManager manages a pool of threads, so we create a * single instance and share it throughout our application. */ AWSCredentials credentials = null; try { credentials = new ProfileCredentialsProvider("default").getCredentials(); } catch (Exception e) { throw new AmazonClientException("Cannot load the credentials from the credential profiles file. " + "Please make sure that your credentials file is at the correct " + "location (/Users/prabhjitsingh/.aws/credentials), and is in valid format.", e); } // Instantiate an Amazon SES client, which will make the service call with the supplied AWS credentials. AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(credentials); // Choose the AWS region of the Amazon SES endpoint you want to connect to. Note that your production // access status, sending limits, and Amazon SES identity-related settings are specific to a given // AWS region, so be sure to select an AWS region in which you set up Amazon SES. Here, we are using // the US East (N. Virginia) region. Examples of other regions that Amazon SES supports are US_WEST_2 // and EU_WEST_1. For a complete list, see http://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html Region REGION = Region.getRegion(Regions.US_EAST_1); client.setRegion(REGION); // Send the email. client.sendEmail(request); System.out.println("Email sent!"); } catch (Exception ex) { System.out.println("The email was not sent."); System.out.println("Error message: " + ex.getMessage()); } }
From source file:com.proofpoint.event.monitor.AmazonModule.java
License:Apache License
@Provides @Singleton private AmazonSimpleEmailService provideAmazonS3(AWSCredentials credentials) { return new AmazonSimpleEmailServiceClient(credentials); }
From source file:com.proofpoint.event.monitor.aws.AmazonModule.java
License:Apache License
@Provides @Singleton private AmazonSimpleEmailService provideAmazonSimpleEmailService(AWSCredentials credentials) { return new AmazonSimpleEmailServiceClient(credentials); }
From source file:com.r573.enfili.common.resource.cloud.aws.ses.SesManager.java
License:Apache License
private SesManager(AWSCredentials awsCredentials, String defaultSender) { client = new AmazonSimpleEmailServiceClient(awsCredentials); this.defaultSender = defaultSender; }
From source file:com.solomon.aws.service.AwsUtil.java
public static AmazonSimpleEmailServiceClient getAwsEmailServClient(AWSCredentials credentials) { return new AmazonSimpleEmailServiceClient(credentials); }