Personal tools
fr.gif, 1 kB    en.gif, 1 kB

Mrs

This page was last modified 12:58, 14 August 2008.

From Milimail

Jump to: navigation, search

> User Manual > Add-on: Message Remote Services

Contents

Add-on: Message Remote Services

Message Remote Services is an add-on for Mozilla Thunderbird which exposes remote services to external processes. A Java API is also proposed to interact with MRS.

Thus, an external Java Program can use a running instance of Thunderbird installed on the same OS.

Features:

  • Sending emails.
  • Browse/Receive emails (Not yet finished)

WARNING:: this add-on is currently an alpha version, meaning it is still in development and it may not work correctly.

Installation

  1. Download the extension (mrs-linux-x86 or mrs-win)
  2. In Mozilla Thunderbird, select Tools menu and then Add-ons.
  3. Press Install button and select previously downloaded file.

Installation of MRS

Configuration

To configure, right-click on the extension in the Add-ons window.

Configuration of MRS

  • Services can be enabled at startup. This feature can be switched off.
  • When this feature is changed, Thunderbird must be restarted.

Java API

The Message Remote Services Extension exposes services which can be called by another application.

This application uses MRS Java API to call these services.

The MRS API is composed of a JAR File (MessageRemoteServices.jar) to be included in the application. The library lib/commons-io-1.4.jar must be installed.

API initialization and services creation

import org.milimail.messageRemoteServiceAPI.init.*;
import org.milimail.messageRemoteServiceAPI.compose.*;
import org.milimail.messageRemoteServiceAPI.account.*;
 
public static void main(String[] args) {
  ServiceCreator serviceCreator = API.init();
  MessageComposeServiceProxy composeService = serviceCreator.createMessageComposeService();
  AccountServiceProxy accountService = serviceCreator.createAccountService();
}

Account Service

//Call to the running Thunderbird, Get all Accounts for the current profile
  List<Account> accounts = accountService.GetAllAccounts();
  for (Account account : accounts) {
    //Server Imap Name			
    String serverName = account.getServerHostName();
    //Account Id
    String key = account.getKey();
    System.out.println(serverName + " " + key);
  }

Compose Service

Send a simple message to a recipient.

ServiceCreator serviceCreator = API.init();
MessageComposeServiceProxy composeService = serviceCreator.createMessageComposeService();
AccountServiceProxy accountService = serviceCreator.createAccountService();
//Simple implementation of MessageSendListener interface which print the Send status
MessageSendListener messageListener = serviceCreator
				.createMessageSendListener(new MessageSendListenerServantConsole());
 
//Take the second Thunderbird's account for the current profile
Account account = accountService.GetAllAccounts().get(1);
 
//Create the message to send
Message message = new Message();
message.setSubject("Subject from API");
message.setBody("body from API");
String[] to = { "user2@test.milimail.org" };
message.setTo(to);
 
//Call to Thunderbird, Callback to messageListener (print status to console)
composeService.sendMessage(account, message, messageListener);
  • Crypt message
Security security = new Security();
security.setCrypted(true);
message.setSecurity(security);
  • Sign message
Security security = new Security();
security.setSigned(true);
message.setSecurity(security);
  • Header
List<Header> headers = new ArrayList<Header>();
Header header0 = new Header();
header0.setKey("X-MRS-TEST-1");
header0.setValue("X-MRS-VALUE-1");
message.setHeaders(headers);
  • MDN Read receipt
Notification notification = new Notification();
notification.setMDNReadRequested(true);
message.setNotification(notification);
  • DSN Delivery receipt
//Only with milimail (thunderbird 2.x patched)
Notification notification = new Notification();
notification.setDSNRequested(true);
message.setNotification(notification);
  • Attachments
List<Attachment> attachments = new ArrayList<Attachment>();
Attachment attachment0 = new Attachment();
attachment0 = new Attachment();
attachment0.setDirPath("/tmp/res/");
attachment0.setFileName("attachment1.txt");
attachment0.setMimeType("text/plain");
attachments.add(attachment0);
message.setAttachments(attachments);

Reference: English – Translations:  Français  • 


Files

Third Party Projects