List of usage examples for com.amazonaws.services.simpleemail.model.transform SendRawEmailResultStaxUnmarshaller SendRawEmailResultStaxUnmarshaller
SendRawEmailResultStaxUnmarshaller
From source file:com.kolich.aws.services.ses.impl.KolichSESClient.java
License:Open Source License
@Override public Either<HttpFailure, SendRawEmailResult> sendRawEmail(final RawMessage message, final String from, final List<String> destinations) { return new AwsSESHttpClosure<SendRawEmailResult>(client_, SC_OK, new SendRawEmailResultStaxUnmarshaller()) { @Override//w w w .j a v a 2s . c o m public void validate() throws Exception { checkNotNull(message, "Raw message cannot be null."); checkNotNull(from, "From email address cannot be null."); checkState(isValidEmail(from), "Invalid 'from' email address, " + "did not match expected email pattern."); } @Override public void prepare(final AwsHttpRequest request) throws Exception { request.addParameter(SES_ACTION_PARAM, SES_ACTION_SENDEMAIL); request.addParameter(SES_SOURCE_ADDRESS_PARAM, from); // Destination addresses for (int i = 0; i < destinations.size(); i++) { final String destination = destinations.get(i); request.addParameterOpt(String.format("%s.%s", SES_DESTINATIONS_PARAM, i + 1), destination); } // Message body request.addParameter(SES_RAW_MESSAGE_DATA_PARAM, fromByteBuffer(message.getData())); } }.post(); }