• 1.10

Object-Oriented Email Sending SDK

It is as simple as this:

import com.jcabi.immutable.Array;
import com.jcabi.email.Enclosure;
import com.jcabi.email.Envelope;
import com.jcabi.email.Postmap;
import com.jcabi.email.wire.SMTP;
import com.jcabi.email.Stamp;
import com.jcabi.email.enclosure.EnBinary;
import com.jcabi.email.enclosure.EnPlain;
import com.jcabi.email.stamp.StBCC;
import com.jcabi.email.stamp.StRecipient;
import com.jcabi.email.stamp.StSender;
import com.jcabi.email.stamp.StSubject;

Postman postman = new Postman.Default(
  new SMTP(
    new Token("user", "password").access(
      new Protocol.SMTP("smtp.gmail.com", 587)
    )
  )
);
postman.send(
  new Envelope.MIME(
    new Array<Stamp>(
      new StSender("Yegor Bugayenko <yegor@jcabi.com>"),
      new StRecipient("Jeff Lebowski <jeff@gmail.com>"),
      new StSubject("dude, how are you?"),
      new StBCC("my-boss@jcabi.com")
    ),
    new Array<Enclosure>(
      new EnPlain("Hi, long time no see! :) Check my pic!"),
      new EnBinary(
        new File("/tmp/picture.gif"),
        "my-picture.gif",
        "image/gif"
      )
    )
  )
);

The only dependency you need is (you can also download jcabi-email-1.10.jar and add it to the classpath):

<dependency>
  <groupId>com.jcabi</groupId>
  <artifactId>jcabi-email</artifactId>
  <version>1.10</version>
</dependency>

Well, you will also need these (in this specific order):

<dependency>
  <groupId>javax.activation</groupId>
  <artifactId>activation</artifactId>
  <version>1.1.1</version>
  <scope>runtime</scope>
</dependency>
<dependency>
  <groupId>javax.mail</groupId>
  <artifactId>mail</artifactId>
  <version>1.5.0-b01</version>
  <scope>runtime</scope>
</dependency>
<dependency>
  <groupId>javax.mail</groupId>
  <artifactId>mailapi</artifactId>
  <version>1.4.3</version>
  <scope>provided</scope>
</dependency>

Cutting Edge Version

If you want to use current version of the product, you can do it with this configuration in your pom.xml:

<repositories>
  <repository>
    <id>oss.sonatype.org</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
  </repository>
</repositories>
<dependencies>
  <dependency>
    <groupId>com.jcabi</groupId>
    <artifactId>jcabi-email</artifactId>
    <version>2.0-SNAPSHOT</version>
  </dependency>
</dependencies>