Usage
Get it now
To use Ogham without any framework, add it to pom.xml:
... <dependencies> ... <dependency> <groupId>fr.sii.ogham</groupId> <artifactId>ogham-core</artifactId> <version>1.1.1</version> </dependency> ... </dependencies> ...
To use Ogham with Spring Boot, just add the following dependency:
... <dependencies> ... <dependency> <groupId>fr.sii.ogham</groupId> <artifactId>ogham-spring</artifactId> <version>1.1.1</version> </dependency> ... </dependencies> ...
Full integration instructions »
Send email
package fr.sii.ogham.sample.standard.email; import java.util.Properties; import fr.sii.ogham.core.builder.MessagingBuilder; import fr.sii.ogham.core.exception.MessagingException; import fr.sii.ogham.core.service.MessagingService; import fr.sii.ogham.email.message.Email; public class BasicSample { public static void main(String[] args) throws MessagingException { // configure properties (could be stored in a properties file or defined // in System properties) Properties properties = new Properties(); properties.put("mail.smtp.host", "<your server host>"); properties.put("mail.smtp.port", "<your server port>"); properties.put("ogham.email.from", "<email address to display for the sender user>"); // Instantiate the messaging service using default behavior and // provided properties MessagingService service = new MessagingBuilder().useAllDefaults(properties).build(); // send the email using constructor service.send(new Email("subject", "email content", "<recipient address>")); // or send email using the fluent API service.send(new Email(). subject("subject"). content("email content"). to("<recipient address>")); } }
Send SMS
package fr.sii.ogham.sample.standard.sms; import java.util.Properties; import fr.sii.ogham.core.builder.MessagingBuilder; import fr.sii.ogham.core.exception.MessagingException; import fr.sii.ogham.core.service.MessagingService; import fr.sii.ogham.sms.message.Sms; public class BasicSample { public static void main(String[] args) throws MessagingException { // configure properties (could be stored in a properties file or defined // in System properties) Properties properties = new Properties(); properties.setProperty("ogham.sms.smpp.host", "<your server host>"); properties.setProperty("ogham.sms.smpp.port", "<your server port>"); properties.setProperty("ogham.sms.smpp.systemId", "<your server system ID>"); properties.setProperty("ogham.sms.smpp.password", "<your server password>"); properties.setProperty("ogham.sms.from", "<phone number to display for the sender>"); // Instantiate the messaging service using default behavior and // provided properties MessagingService service = new MessagingBuilder().useAllDefaults(properties).build(); // send the sms using constructor service.send(new Sms("sms content", "<recipient phone number>")); // or send sms using fluent API service.send(new Sms(). content("sms content"). to("<recipient phone number>")); } }
Use with Spring
Once Ogham is integrated with Spring, you can simply inject MessagingService where you need it.