/*
* Important: Be sure to fill in your AWS access credentials in the
* AwsCredentials.properties file before you try to run this sample.
* http://aws.amazon.com/security-credentials
*/
PropertiesCredentials credentials = new PropertiesCredentials(
AWSJavaMailSample.class
.getResourceAsStream("AwsCredentials.properties"));
AmazonSimpleEmailService ses = new AmazonSimpleEmailServiceClient(credentials);
/*
* Before you can send email via Amazon SES, you need to verify that you
* own the email address from which you�ll be sending email. This will
* trigger a verification email, which will contain a link that you can
* click on to complete the verification process.
*/
verifyEmailAddress(ses, FROM);
/*
* If you've just signed up for SES, then you'll be placed in the Amazon
* SES sandbox, where you must also verify the email addresses you want
* to send mail to.
*
* You can uncomment the line below to verify the TO address in this
* sample.
*
* Once you have full access to Amazon SES, you will *not* be required
* to verify each email address you want to send mail to.
*
* You can request full access to Amazon SES here:
* http://aws.amazon.com/ses/fullaccessrequest
*/
//verifyEmailAddress(ses, TO);
/*
* Setup JavaMail to use the Amazon Simple Email Service by specifying
* the "aws" protocol.
*/
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "aws");
/*
* Setting mail.aws.user and mail.aws.password are optional. Setting
* these will allow you to send mail using the static transport send()
* convince method. It will also allow you to call connect() with no
* parameters. Otherwise, a user name and password must be specified
* in connect.
*/
props.setProperty("mail.aws.user", credentials.getAWSAccessKeyId());
props.setProperty("mail.aws.password", credentials.getAWSSecretKey());
Session session = Session.getInstance(props);
try {
// Create a new Message