Table of Contents | ||
---|---|---|
|
...
Excerpt |
---|
Amdatu Email provides a service abstraction for sending email. Currently, it provides implementations to send emails through Amazon's Simple Email Service, through a configured SMTP server, as well as a mock implementation for use in test scenario's. |
Usage
Deploy the preferred email service bundle; `org.amdatu.email.smtp` or `org.amdatu.email.aws` with your application and inject the EmailService into components as desired. The EmailService then allows you to send emails through the configured email server.
Dependencies
The Amdatu Email bundle depends on the following bundles:
- Apache Felix DependencyManager v3.1.0;
- An OSGi ConfigurationAdmin service implementation, for example Apache Felix ConfigAdmin v1.8.0;
- (Optionally) an OSGi LogService implementation, for example Apache Felix LogService v1.0.1.
Configuration and example use
AWS Email Server
AWSEmailService is configured by providing a configuration for the PID `org.amdatu.email.aws`. Configuration is done by setting the required `aws-key`, `aws-secret` and optional `aws-region` properties.
When no region is specified, the default region will be chosen.
The following example shows how to send an email through the configured AWSEmailService:
Code Block | ||||
---|---|---|---|---|
| ||||
instance.send(Message.Builder.create().recipient("success@simulator.amazonses.com").htmlBody("test")
.subject("test").from("test@amdatu.com").build()); |
...
SMTPEmailService is configured by providing a configuration for the PID `org.amdatu.email.smtp`. Configuration is done by setting the required `smtp-host`, `smtp-user`, `smtp-password` and optional `smtp-port`, `smtp-use-ssl`, `smtp-from-name` and `smtp-from-email` properties.
When no port, use-ssl, from-name and from-email properties have been specified, email will be sent through port 25, not using SSL, from user `Amdatu Mail Service` and address `noreply@amdatu.org` by default.
The following example shows how to send an email through the configured SMTPEmailService:
Code Block | ||||
---|---|---|---|---|
| ||||
String testBody = "Amdatu Mail Service Test";
String testSubject = "Test Message";
instance.send(Message.Builder.create().recipient("someone@example.com").textBody(testBody).subject(testSubject)
.from("test@amdatu.org").build()); |
License
The Amdatu MongoDB project is licensed underĀ Apache License 2.0
. |