When this library is added to a project it allows for email sending capabilities.
Add the following as a dependency in your pom.xml
<dependency>
<groupId>edu.iu.uits.lms</groupId>
<artifactId>lms-email-service</artifactId>
<version><!-- latest version --></version>
</dependency>
You can find the latest version in Maven Central.
Add to any configuration class, or even the main application class @EnableEmailClient
.
Once that has been done, you can autowire in and use the email service:
@Autowired
private EmailService emailService;
If choosing to use properties files for the configuration values, the default location is /usr/src/app/config
, but that can be overridden by setting the app.fullFilePath
value via system property or environment variable.
The following properties need to be set to configure the communication with a database. They can be set in a security.properties file, or overridden as environment variables.
Property | Default Value | Description |
---|---|---|
spring.mail.host |
mail-relay.iu.edu | Hostname of the mail relay |
spring.mail.port |
587 | Port of the mail relay |
spring.mail.username |
lmssmtp | Username for sending email |
smtpPassword |
Password for sending email | |
spring.mail.password |
${smtpPassword} |
Password for sending email |
spring.mail.properties.mail.smtp.auth |
true | Additional JavaMail Session properties |
spring.mail.properties.mail.smtp.starttls.enable |
true | Additional JavaMail Session properties |
lmsemail.enabled |
true | Enable/disable email sending |
lmsemail.signingEnabled |
true | Enable/disable digitally signing emails |
lmsemail.defaultFrom |
noreply@iu.edu | Default from address |
lmsemail.defaultUnsignedTo |
iu-uits-es-ess-lms-notify@exchange.iu.edu | Default recipient for emails in test environments |
If you would like to expose the email endpoints in a tool, you will
need to enable it by including the value emailrest
into the SPRING_PROFILES_ACTIVE
environment variable. Be aware that if the tool requires multiple values, that there could be more than one profile value in there.
In order to get access to the endpoints, you'd need to configure an OAuth2 server. Once setup, the user(s) needing access
would have to be granted the email:send
scope. Grant type should be set as Authorization Code
.
See the wiki for details.
To generate the REST docs (asciidoc) that live in the github wiki, take the following steps:
- Enable the rest endpoints and swagger in the tool of choice and start it up
- Note the api docs url. Should be something like http://localhost:8080/api/email/v3/api-docs
- Download the openapi-generator from here
- Run the following (:warning: Command could be slightly different based on your OS and install method):
openapi-generator generate -g asciidoc -i <url_from_above_step>
- Take the generated output and update the wiki page (:warning: Some hand editing may be required)