Parsing E-mail message with Kotlin (Java)

Because it’s hard to use JavaMail alone, use Apache Commons Email. build.gradle dependencies { compile 'javax.mail:mail:1.4.7' compile 'org.apache.commons:commons-email:1.5' } Kotlin import org.apache.commons.mail.util.MimeMessageParser import java.io.ByteArrayInputStream import java.io.IOException import java.util.Properties import javax.mail.MessagingException import javax.mail.Session import javax.mail.internet.InternetAddress import javax.mail.internet.MimeMessage ... fun parse(rawMimeMessage: String): MailData? = ByteArrayInputStream(rawMimeMessage.toByteArray()).use { try { val session = Session.getDefaultInstance(Properties()) val parser = MimeMessageParser(MimeMessage(session, it)) parser.parse() MailData( parser.from, parser.replyTo ?: parser.from, parser.to.map { (it as InternetAddress).address }, parser.cc.map { (it

Read More →

Spring Boot2 multi module project with Gradle

This is how to use Gradle + Spring Boot Gradle Plugin in multiple module configuration. Gradle Root Module In the build.gradle on the Root Module side, Write “bootJar.enabled = false” and “jar.enabled = true”. plugins { id 'org.springframework.boot' version '2.0.3.RELEASE' } ... bootJar.enabled = false jar.enabled = true Sub Module We just add the Sub Module to the dependencies without considering anything. plugins { id 'org.springframework.boot' version '2.0.3.RELEASE' } ...

Read More →