Selenium library

Mail7 Selenium library form disposable email service.


How to use Mail7 with Selenium library?

  • We can read email using the Java library from Mail7.
  • Here is the very basic program to explain How to read email using the Java library.
package com.helloselenium.selenium.test;

import java.util.Properties;
import main.java.io.mail7.sdk.Mail7;

public class GetEMailUsingJavaMailFromMail7{
	public static void main(String[] args) {
		private Mail7SDK.Initialize init = new Mail7SDK.Initialize();
		
		init.setApiKey("___MAIL7_APIKEY___");
		init.setApiSecret("___MAIL7_APISECRET___");

		EmailApi Mail7EmailAPI = new EmailApi();
 
		Mail7EmailAPI.getEmails(username, domain, new AsyncHandler<InboxResponse>() {

				@Override
				public void onSuccess(InboxResponse response) {
					System.out.printlngson.toJson(response));
				}
				@Override
				public void onFailure(ErrorResponse error) {
					System.out.println(error.getMessage());
				}
		});
	}
}

Detailed explanation for the above program is as follows:

Following code is the required packages for Java and Java Mail API library.

import main.java.io.mail7.sdk.Mail7;

Following code is to setup the Mail7 server with API Credentials.

private Mail7SDK.Initialize init = new Mail7SDK.Initialize();
init.setApiKey("___MAIL7_APIKEY___");
init.setApiSecret("___MAIL7_APISECRET___");

Following code is to request an email message by API.

EmailApi Mail7EmailAPI = new EmailApi();
Mail7EmailAPI.getEmails(username, domain, new AsyncHandler<InboxResponse>() {

	@Override
	public void onSuccess(InboxResponse response) {
		System.out.printlngson.toJson(response));
	}

	@Override
	public void onFailure(ErrorResponse error) {
		System.out.println(error.getMessage());
	}
});

Mail7 Also Support Following Functions to trigger another respective services

Emails API:

Get allEmails

EmailApi Mail7EmailAPI = new EmailApi();
Mail7EmailAPI.getEmails(username, domain, new AsyncHandler<InboxResponse>() {
	@Override
	public void onSuccess(InboxResponse response) {
		System.out.printlngson.toJson(response));
	}
	@Override
	public void onFailure(ErrorResponse error) {
		System.out.println(error.getMessage());
	}
});

Get Email By MessageId

EmailApi Mail7EmailAPI = new EmailApi();
Mail7EmailAPI.getEmailByMesssageId(username, domain, messageId, new AsyncHandler<EmailResponse>() {

	@Override
	public void onSuccess(EmailResponse response) {
		System.out.printlngson.toJson(response));
	}
	@Override
	public void onFailure(ErrorResponse error) {
		System.out.println(error.getMessage());
	}
});

delete Email By MessageId

EmailApi Mail7EmailAPI = new EmailApi();
Mail7EmailAPI.deleteEmailByMesssageId(username, domain, messageId, new AsyncHandler<ApiResponse>() {
	@Override
	public void onSuccess(ApiResponse response) {
		System.out.printlngson.toJson(response));
	}
	@Override
	public void onFailure(ErrorResponse error) {
		System.out.println(error.getMessage());
	}
});

Routing Rules API:

Get All Routing Rules

RoutingRuleApi Mail7RoutingRuleAPI = new RoutingRuleApi();
Mail7RoutingRuleAPI.getRoutingRules(new AsyncHandler<RoutingRule>() {
	@Override
	public void onSuccess(RoutingRule response) {
		System.out.printlngson.toJson(response));
	}
	@Override
	public void onFailure(ErrorResponse error) {
		System.out.println(error.getMessage());
	}
});

Create Update Routing Rule

RoutingRuleApi Mail7RoutingRuleAPI = new RoutingRuleApi();
Mail7RoutingRuleAPI.createUpdateRoutingRules(payload, new AsyncHandler<ApiResponse>() {
	@Override
	public void onSuccess(ApiResponse response) {
		System.out.printlngson.toJson(response));
	}
	@Override
	public void onFailure(ErrorResponse error) {
		System.out.println(error.getMessage());
	}
});

Delete Routing Rule

RoutingRuleApi Mail7RoutingRuleAPI = new RoutingRuleApi();
Mail7RoutingRuleAPI.deleteRoutingRules(ruleName, new AsyncHandler<ApiResponse>() {
	@Override
	public void onSuccess(ApiResponse response) {
		System.out.printlngson.toJson(response));
	}
	@Override
	public void onFailure(ErrorResponse error) {
		System.out.println(error.getMessage());
	}
});