org.mule.module

mule-module-gmail

config

Namespacehttp://www.mulesoft.org/schema/mule/gmail
Schema Locationhttp://www.mulesoft.org/schema/mule/gmail/current/mule-gmail.xsd  (View Schema)
Schema Version1.0
Minimum Mule Version3.3

Module Overview

Gmail cloud connector. This connector covers the standard IMAP protocol plus Google's extensions for Gmail. This implementation uses basic authentication

Summary

Configuration
<gmail:config>
Configure an instance of this module
Message Processors
<gmail:advanced-search>
Search and returns messages on a folder of the given username using a search criteria provided by the user via the searchTerm parameter.
<gmail:delete>
Moves the given message to the trash and deletes it from its current folder
<gmail:search>
Returns messages in the user mailbox applying optional search criterias.

Configuration

To use the this module within a flow the namespace to the module must be included. The resulting flow will look similar to the following:

<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:gmail="http://www.mulesoft.org/schema/mule/gmail"
      xsi:schemaLocation="
               http://www.mulesoft.org/schema/mule/core
               http://www.mulesoft.org/schema/mule/core/current/mule.xsd
               http://www.mulesoft.org/schema/mule/gmail
               http://www.mulesoft.org/schema/mule/gmail/current/mule-gmail.xsd">

      <!-- here goes your flows and configuration elements -->

</mule>

Message Processors

<gmail:advanced-search>

Search and returns messages on a folder of the given username using a search criteria provided by the user via the searchTerm parameter. Returns messages in the user mailbox applying optional search criterias. The messages are returned in the form of MailMessage instances which allows the connector's user to be decoupled from the IMAP protocol internals but also allows for the mailbox connection to be closed automatically.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescriptionJava TypeMIME TypeEncoding
config-ref Optional. Specify which configuration to use.
username The account's username String */* UTF-8
password Optional. Only needed is you're using basic authentication. If you're using OAuth2 then this parameter is not used String */* UTF-8
folder The folder in which to search. If you want all of them then use ALL_MAIL GmailFolder */*
searchTerm An instance of SearchTerm. If not provided, then no filtering criteria is applied SearchTerm */*
expunge false Optional. If true, all read messages will be deleted upon operation completion Boolean */*
includeAttachments false Optional. Wether or not to also download the message's attachments. Default value is false bandwidth wise. Boolean */*
Returns
Return Type Description
List<MailMessage> a list of MailMessage representing the found messages
Exception Payloads
Payload ClassDescription
MessagingException if an error is found accessing the mailbox

<gmail:delete>

Moves the given message to the trash and deletes it from its current folder

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescriptionJava TypeMIME TypeEncoding
config-ref Optional. Specify which configuration to use.
mailMessage #[payload] Optional. An instance of MailMessage representing the message to be deleted. At the very least, the googleId property must be not null MailMessage */*
username The mailbox username String */* UTF-8
password Optional. Optional value only required when using basic auth. Ignore this if you're using OAuth String */* UTF-8
Exception Payloads
Payload ClassDescription
MessagingException if the mailbox throws an exception
IllegalArgumentException if the mailbox contains no email with that id

<gmail:search>

Returns messages in the user mailbox applying optional search criterias. The messages are returned in the form of MailMessage instances which allows the connector's user to be decoupled from the IMAP protocol internals but also allows for the mailbox connection to be closed automatically.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescriptionJava TypeMIME TypeEncoding
config-ref Optional. Specify which configuration to use.
username The account's username String */* UTF-8
folder The folder in which to search. If you want all of them then use ALL_MAIL GmailFolder */*
password Optional. Only needed is you're using basic authentication. If you're using OAuth2 then this parameter is not used String */* UTF-8
receivedBefore Optional. A date in the specified string format giving a lower bound filter to the received date. If no dateFormat is specified, then RFC3339 is assumed String */* UTF-8
receivedAfter Optional. A date in the specified string format giving an upper bound filter to the received date. If no dateFormat is specified, then RFC3339 is assumed String */* UTF-8
sentBefore Optional. A date in the specified string format giving a lower bound filter to the sent date. If no dateFormat is specified, then RFC3339 is assumed String */* UTF-8
sentAfter Optional. A date in the specified string format giving an upper bound filter to the sent date. If no dateFormat is specified, then RFC3339 is assumed String */* UTF-8
messageNumber Optional. Used to look for the message with the specified number Integer */*
size Optional. An instance of SearchCriteria to specify restrictions on the message's size SearchCriteria */*
threadId Optional. The id of the thread for which the message should belong String */* UTF-8
messageId Optional. Used to fetch one given message by id String */* UTF-8
dateFormat yyyy-MM-dd\'T\'HH:mm:ss\'Z\' Optional. The format to be used to parse the date attributes. If no dateFormat is specified, then RFC3339 is assumed String */* UTF-8
expunge false Optional. If true, all read messages will be deleted upon operation completion Boolean */*
includeAttachments false Optional. Wether or not to also download the message's attachments. Default value is false bandwidth wise. Boolean */*
Child Elements
NameDefault ValueDescriptionJava Type
<gmail:from-addresses> Optional. A list of addresses to be found in the from attribute. This is an OR operation logic. All messages with any one of these addresses will be returned List<String>
<gmail:to-addresses> Optional. A list of addresses to be found in the to attribute. This is an OR operation logic. All messages with any one of these addresses will be returned List<String>
<gmail:flags> Optional. A list of FlagCriteria to specify flag values that the messages should have List<FlagCriteria>
<gmail:labels> Optional. A list of Strings which represent the labels that the messages need to have. This is an OR operation logic. All messages with any one of these labels will be returned List<String>
<gmail:raw-search-terms> Optional. A list of Strings which represent terms that the message should have. This is an OR operation logic. All messages with any one of these terms will be returned List<String>
<gmail:body-terms> Optional. A list of Strings which represent the body terms that the messages need to have. This is an OR operation logic. All messages with any one of these terms will be returned List<String>
<gmail:header-terms> Optional. A list of Strings which represent the header terms that the messages need to have. This is an OR operation logic. All messages with any one of these terms will be returned List<String>
<gmail:subject-terms> Optional. A list of Strings which represent the subject terms that the messages need to have. This is an OR operation logic. All messages with any one of these terms will be returned List<String>
Returns
Return Type Description
List<MailMessage> a list of MailMessage
Exception Payloads
Payload ClassDescription
MessagingException if an error is found accessing the mailbox

Message Sources

Transformers