Skip to content

truemail-rb/truemail-java-client

Repository files navigation

Truemail web API client library for Java

CircleCI Maven Central GitHub Gitter Contributor Covenant

truemail-java-client - Web API Java client for Truemail Server.

Actual and maintainable documentation 📚 for developers is living here.

Table of Contents

Requirements

Java 1.8+

Installation

Please change {version} to needed version, for example 0.1.0. All available versions you can find here.

Apache Maven

<dependency>
  <groupId>org.truemail-rb</groupId>
  <artifactId>truemail-java-client</artifactId>
  <version>{version}</version>
</dependency>

Gradle Groovy

implementation 'org.truemail-rb:truemail-java-client:{version}'

Apache Ivy

<dependency org="org.truemail-rb" name="truemail-java-client" rev="{version}" />

Groovy Grape

@Grapes(
  @Grab(group='org.truemail-rb', module='truemail-java-client', version='{version}')
)

Usage

import org.truemail_rb.TruemailClient;
import org.truemail_rb.client.TruemailConfiguration;

To have an access for TruemailClient#validate you must create configuration instance first as in the example below:

Creating configuration instance

// Required parameter. It should be true or false
boolean secureConnection = true;

// Required parameter. It should be a hostname or an ip address where Truemail server runs
String host = "example.com";

// Optional parameter. By default it is equal 9292
int port = 80;

// Required parameter. It should be valid Truemail server access token
String token = "token";

TruemailConfiguration truemailConfiguration = new TruemailConfiguration(secureConnection, host, token, port);

// or without port, will be used 9292 port by default
// TruemailConfiguration truemailConfiguration = new TruemailConfiguration(secureConnection, host, token);

Establishing connection with Truemail API

After successful configuration, you can establish connection with Truemail server.

TruemailClient truemailClient = new TruemailClient(truemailConfiguration);
truemailClient.validate("[email protected]")

=>

{
  "date": "2020-10-26 10:42:42 +0200",
  "email": "[email protected]",
  "validation_type": "smtp",
  "success": true,
  "errors": null,
  "smtp_debug": null,
  "configuration": {
    "validation_type_by_domain": null,
    "whitelist_validation": false,
    "whitelisted_domains": null,
    "blacklisted_domains": null,
    "smtp_safe_check": false,
    "email_pattern": "default gem value",
    "smtp_error_body_pattern": "default gem value"
  }
}

TruemailClient#validate always returns JSON data. If something goes wrong you will receive JSON with error details:

{
  "truemail_client_error": "error details"
}

Truemail family

All Truemail solutions: https://truemail-rb.org

Name Type Description
truemail ruby gem Configurable plain Ruby email validator, main core
truemail-go go package Configurable Golang email validator, main core
truemail server ruby app Lightweight rack based web API wrapper for Truemail
truemail-rack-docker docker image Lightweight rack based web API dockerized image 🐳 of Truemail server
truemail-ruby-client ruby gem Web API Ruby client for Truemail Server
truemail-crystal-client crystal shard Web API Crystal client for Truemail Server
truemail-rspec ruby gem Truemail configuration, auditor and validator RSpec helpers

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/truemail-rb/truemail-java-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct. Please check the open tikets. Be shure to follow Contributor Code of Conduct below and our Contributing Guidelines.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the truemail-java-client project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Credits

Versioning

truemail-java-client uses Semantic Versioning 2.0.0