mbox4j

Simplify the manipulations with emails for Java-based applications.

License

License

${project.licence}
GroupId

GroupId

io.github.dgroup
ArtifactId

ArtifactId

mbox4j
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

mbox4j
Simplify the manipulations with emails for Java-based applications.
Project URL

Project URL

http://github.com/dgroup/mbox4j
Source Code Management

Source Code Management

http://github.com/dgroup/mbox4j/tree/master

Download mbox4j

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.dgroup/mbox4j/ -->
<dependency>
    <groupId>io.github.dgroup</groupId>
    <artifactId>mbox4j</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.dgroup/mbox4j/
implementation 'io.github.dgroup:mbox4j:0.1.1'
// https://jarcasting.com/artifacts/io.github.dgroup/mbox4j/
implementation ("io.github.dgroup:mbox4j:0.1.1")
'io.github.dgroup:mbox4j:jar:0.1.1'
<dependency org="io.github.dgroup" name="mbox4j" rev="0.1.1">
  <artifact name="mbox4j" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.dgroup', module='mbox4j', version='0.1.1')
)
libraryDependencies += "io.github.dgroup" % "mbox4j" % "0.1.1"
[io.github.dgroup/mbox4j "0.1.1"]

Dependencies

provided (3)

Group / Artifact Type Version
org.cactoos : cactoos jar 0.42
javax.mail : mail jar 1.5.0-b01
org.hamcrest : hamcrest-all jar 1.3

test (3)

Group / Artifact Type Version
org.llorllale : cactoos-matchers jar 0.17
junit : junit jar 4.12
io.github.dgroup : term4j jar 0.4.0

Project Modules

There are no modules declared in this project.

Maven Javadocs License: MIT Commit activity Hits-of-Code

Build Status 0pdd Dependency Status Known Vulnerabilities

DevOps By Rultor.com EO badge We recommend IntelliJ IDEA

Qulice SQ maintainability Codebeat Codacy Badge Codecov

What it is

mbox4j is an object-oriented primitives to simplify the manipulations with emails for Java-based applications.

Principles

Design principles behind mbox4j.

How to use

Get the latest version here:

<dependency>
    <groupId>io.github.dgroup</groupId>
    <artifactId>mbox4j</artifactId>
    <version>${version}</version>
</dependency>

Java version required: 1.8+.

Interface Purpose Implementations / Related
Inbox Allows to read the emails from the server JavaxMailInbox, InboxEnvelope, UncheckedInbox, FakeInbox, etc
Outbox Allows to send the emails to the target recipients JavaxMailOutbox, OutboxEnvelope, UncheckedOutbox, FakeOutbox, etc
Msg The email message to be read/sent MsgOf, MsgEnvelope, FakeMsg, etc
Query Email search query to the server QueryOf, Mode, ModeOf, All, etc

All examples below are using the following frameworks/libs:

  • Hamcrest - Library of matchers, which can be combined in to create flexible expressions of intent in tests.
  • cactoos - Object-Oriented Java primitives, as an alternative to Google Guava and Apache Commons.
  • cactoos-matchers - Object-Oriented Hamcrest matchers

Inbox

JavaxMailInbox

Fetch the emails from the server using javax.mail framework:

public static void main(final String[] args) {
    final Properties smtp = new Properties();
    smtp.setProperty("mail.smtp.host", host);
    smtp.setProperty("mail.smtp.port", port);
    smtp.setProperty("username", user);
    smtp.setProperty("password", password);
    ...
    final Inbox inbox = new JavaxMailInbox(smtp);
    final Iterable<Msg> msgs = inbox.read(
        new Query("pop3s", "INBOX", new All())
    );
    for(final Msg msg : msgs) {
        System.out.println(msg);
    }
}

See Gmail SMTP connection properties as an example of a configuration for reading procedure.

Outbox

JavaxMailOutbox

Send an email to the target recipients using javax.mail framework:

public static void main(final String[] args) {
    final Properties smtp = new Properties();
    smtp.setProperty("mail.smtp.host", host);
    smtp.setProperty("mail.smtp.port", port);
    smtp.setProperty("username", user);
    smtp.setProperty("password", password);
    ...
    final Outbox outbox = new JavaxMailOutbox(smtp);
    outbox.send(
        new MsgOf(
            "[email protected]", 
            "[email protected]", 
            "Testing subj", 
            "I'm simple and i know it."
        )
    );
}

See Gmail SMTP connection properties as an example of a configuration for sending procedure.

Versions

Version
0.1.1
0.1.0