This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl localhost:8080/email | |
Email sent. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Post(uri="/attachment", produces="text/plain", consumes = MediaType.MULTIPART_FORM_DATA) | |
public String attachment(CompletedFileUpload file) throws IOException { | |
Email.Builder emailBuilder = Email.builder() | |
.to("pipar27174@shackvine.com") | |
.subject("Micronaut Email Attachment Test: " + LocalDateTime.now()) | |
.body("This is an email") | |
.attachment( | |
Attachment.builder() | |
.filename(file.getFilename()) | |
.contentType(file.getContentType().isPresent() ? file.getContentType().get().toString() : MediaType.APPLICATION_OCTET_STREAM) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" xmlns:th="http://www.thymeleaf.org"> | |
<body> | |
<p> | |
Hello, <span th:text="${name}"></span>! | |
</p> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -X POST \ | |
-H "Content-Type: multipart/form-data" \ | |
-F "file=@/Users/trsharp/Pictures/demo/apple.jpg" \ | |
localhost:8080/email/attachment | |
Email sent. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Get(uri="/template/{name}", produces="text/plain") | |
public String template(@PathVariable String name) { | |
Map model = CollectionUtils.mapOf("name", name); | |
Email.Builder emailBuilder = Email.builder() | |
.to("pipar27174@shackvine.com") | |
.subject("Micronaut Email Template Test: " + LocalDateTime.now()) | |
.body(new TemplateBody<>(BodyType.HTML, new ModelAndView<>("email", model))); | |
emailSender.send(emailBuilder); | |
return "Email sent."; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Controller("/email") | |
public class EmailController { | |
private final EmailSender emailSender; | |
public EmailController(EmailSender emailSender) { | |
this.emailSender = emailSender; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl localhost:8080/email/template/Todd%20Sharp | |
Email sent. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
public class OciSessionProvider implements SessionProvider { | |
private final Properties properties; | |
private final String user; | |
private final String password; | |
public OciSessionProvider( | |
MailPropertiesProvider properties, | |
@Property(name = "codes.recursive.smtp.user") String user, | |
@Property(name = "codes.recursive.smtp.password") String password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javamail: | |
properties: | |
mail: | |
smtp: | |
port: 587 | |
auth: true | |
starttls: | |
enable: true | |
host: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
micronaut: | |
application: | |
name: mnOciEmail | |
email: | |
from: | |
email: default@email.com | |
name: Email User |