Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.jonjomckay:simple-java-mail:4.2.1'
}
dependencies {
implementation("com.github.jonjomckay:simple-java-mail:4.2.1")
}
<dependency>
<groupId>com.github.jonjomckay</groupId>
<artifactId>simple-java-mail</artifactId>
<version>4.2.1</version>
</dependency>
libraryDependencies += "com.github.jonjomckay" % "simple-java-mail" % "4.2.1"
:dependencies [[com.github.jonjomckay/simple-java-mail "4.2.1"]]
Simple Java Mail is the simplest to use lightweight mailing library for Java, while being able to send complex emails including authenticated socks proxy(!), attachments, embedded images, custom headers and properties, robust address validation, build pattern and even DKIM signing and external configuration files with property overriding, Spring support and Email conversion tools. Just send your emails without dealing with RFC's.
The Simple Java Mail library is a thin layer on top of the JavaMail smtp mailing API that allows users to define emails on a high abstraction level without having to deal with mumbo jumbo such a 'multipart' and 'mimemessage'.
ConfigLoader.loadProperties("simplejavamail.properties"); // optional default
ConfigLoader.loadProperties("overrides.properties"); // optional extra
Email email = new Email();
email.setFromAddress("lollypop", "lolly.pop@mymail.com");
email.setReplyToAddress("lollypop", "lolly.pop@othermail.com");
email.addRecipient("lollypop", "lolly.pop@somemail.com", Message.RecipientType.TO);
email.addRecipient("C. Cane", "candycane@candyshop.org", Message.RecipientType.TO);
email.addRecipient("C. Bo", "chocobo@candyshop.org", Message.RecipientType.CC);
email.setSubject("hey");
email.setText("We should meet up! ;)");
email.setTextHTML("<img src='cid:wink1'><b>We should meet up!</b><img src='cid:wink2'>");
email.addEmbeddedImage("wink1", imageByteArray, "image/png");
email.addEmbeddedImage("wink2", imageDatesource);
email.addAttachment("invitation", pdfByteArray, "application/pdf");
email.addAttachment("dresscode", odfDatasource);
email.signWithDomainKey(privateKeyData, "somemail.com", "selector");
new Mailer(
new ServerConfig("smtp.host.com", 587, "user@host.com", "password"),
TransportStrategy.SMTP_TLS,
new ProxyConfig("socksproxy.host.com", 1080, "proxy user", "proxy password")
).sendMail(email);
Simple Java Mail is available in Maven Central:
<dependency>
<groupId>org.simplejavamail</groupId>
<artifactId>simple-java-mail</artifactId>
<version>4.2.1</version>
<!--version>4.2.1-java6-release</version-->
</dependency>
v4.2.1 (12-Feb-2017)
Patch: streamlined convenience methods for adding recipients.
v4.2.0 (12-Feb-2017)
Major feature: Using the EmailConverter you can now convert between Outlook .msg, EML, MimeMessage and Email!
Note: Starting this release, there will always be a Java6 compatible release as well versioned: "x.y.z-java6-release"
v4.1.3 (28-Jan-2017)
NOTE: ConfigLoader moved from /internal/util
to /util
v4.1.2 (07-Nov-2016)
v4.1.1 (30-Jul-2016)
v4.1.0 (22-Jul-2016)
v4.0.0 (05-Jul-2016)
NOTE: All packages have been renamed to "org.simplejavamail.(..)" NOTE: Switched to Java 7
v3.1.1 (11-May-2016)
Major feature: DKIM support!
NOTE: this is the last release still using Java 6. Next release will be using Java 7. /edit: starting with 4.2.0 every release will now have a "x.y.z-java6-release" release as well
v3.0.2 (07-May-2016)
v3.0.1 (29-Feb-2016)
v3.0.0 (26-Feb-2016)
v2.5.1 (19-Jan-2016)
v2.5 (19-Jan-2016)
v2.4 (12-Aug-2015)
v2.3 (21-Jul-2015)
v2.2 (09-May-2015)
v2.1 (09-Aug-2012)
v2.0 (20-Aug-2011)
v1.9.1 (08-Aug-2011)
v1.9 (6-Aug-2011)
v1.8
v1.7 (22-Mar-2011)
Added support for SSL! (tested with gmail)
known possible issue: SSL self-signed certificates might not work (yet). Please let me know by e-mail or create a new issue
v1.6
Completed migration to Java Simple Mail project.
v1.4 (15-Jan-2011)
vX.X (26-Apr-2009)