Graph Mail Documentation

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Graph-Mail

Purpose
This program uses Azure Graph platform to send and read microsoft emails, Using Wildfly
ActiveMQ queue to comunicate with SM project. This integration can be used in the same time
with SM project's POP3, SMTP and IMAP configuration.
The e-mail reading is performed to trigger automatic actions in the SM project by sending e-mails
to a specific mailbox and filtering for a list of folders defined in the automatic actions register
and in the config: GRAPH_MAIL_FOLDERS_LIST.

Azure
It is necessary to register an APP on the Microsoft Azure platform and give the following
permissions:
Mail.Send
Mail.Send.Shared
Mail.Read
Mail.Read.Shared
Mail.ReadWrite
Mail.ReadWrite.Shared

WildFly
standalone.xml
user:
Create jms user for communication, command line example:
sh add-user.sh -a -u jmsuser -p 1 -g guest\

Queue config:
In config files, like standalone.xml in tag <subsystem
xmlns="urn:jboss:domain:messaging-activemq:3.0"> put ActiveMQ queue
config tag, one for send and another to read emails. Example:
<jms-queue name="graphMailQueue" entries="queue/graphMailQueue
java:jboss/exported/jms/queue/queue/graphMailQueue"/>
<jms-queue name="readGraphMailQueue" entries="queue/readGraphMailQueue
java:jboss/exported/jms/queue/queue/readGraphMailQueue"/>

System Properties:
We need to configure in standalone.xml, a system property to define dynamic listeners list for the
existing queues for receive emails from Graph-Mail project. Example:
<property name="jms.readGraphMailQueue.list" value="readGraphMailQueue,
readGraphMailQueue2, readGraphMailQueue3"/>\

Graph-Mail Config file:


Put a config.properties file in the same directory of graph-mail.jar file. Content example:
JMS_CONNECTION_FACTORY_JNDI = jms/RemoteConnectionFactory
JMS_WILDFLY_REMOTING_URL = http-remoting://127.0.0.1:8080
JMS_QUEUE_JNDI = jms/queue/queue/graphMailQueue
JMS_READ_MAIL_QUEUE_JNDI = jms/queue/queue/readGraphMailQueue
JMS_USERNAME = jmsuser
JMS_PASSWORD = [password]
GRAPH_APP_ID = [APP ID Azure]
GRAPH_USERNAME = [microsoft mail]
GRAPH_PASSWORD = [microsoft password]
GRAPH_MAIL_FOLDERS_LIST = folder, folder2, folder3
GRAPH_MAIL_PROCESSED_FOLDER = processed
ATTACHMENTS_FILE_PATH = /opt/attachments/

SM - Service Management

For send microsoft emails, configure:


Parameter
• Parameter 477 defines that GraphMail program will be used to send emails and usind default
queue name graphMailQueue. Data:
ID = 477
Type = Text
Content = Authentication Type for sending emails
Description =

pt - Tipo de autenticação de e-mail


en - Mail authentication type
es - Tipo de autenticación de correo

or Mailbox screen:
• If you use e-mail boxes per contract, so configure them with one queue name for each mail
box and choose in Mail authentication type Microsoft Graph Mail

For read microsoft emails, configure:


Automatic action configuration via email screen
• Choose in Mail authentication type field: Microsoft Graph Mail
• Fill Microsoft Graph Mail Queue field with name of queue defined in standalone.xml - in
queue tag and system property jms.readGraphMailQueue.list.
• Filt Inbox Folder with folder name existing inside that mailbox configured and listed in
GRAPH_MAIL_FOLDERS_LIST
Configuring attchments files
To transmit attached files from one project to another, it is necessary to configure parameter 479
with the directory external to Wildfly and which will be used to map the projects' docker volumes.
Data:
ID = 479
Type = Text
Content = Directory path mapped to GraphMail container volume
Description =

pt - Diretório de anexos para envio de e-mail


en - Attachments directory for sending e-mail
es - Directorio de archivos adjuntos para enviar correo electrónico

Creating a Graph-Mail docker container


The Graph-Mail application is used as a docker container. To do this, use the docker-compose file,
which is available from the docker directory of this project.
To download the docker image referring to Graph-Mail, it is necessary that the docker service is
connected to the centralit nexus service (https://nexus.centralit.io). For more information, contact
the responsible infrastructure service.

Configuring docker compose file


A docker compose to set up Graph-Mail service should be as show below. To configure the file
correctly, replace the following variables with the corresponding values
version: '3.7'
services:
graphmail:
image: nexus.centralit.io:9091/graphmail:1.1.0
container_name: graphmail
network_mode: "host"
volumes:
- ${CONFIG_PROPERTIES_FILE_PATH}:/opt/graphmail/config.properties:ro
- ${ATTACHMENTS_DIRECTORY}:/opt/attachments:rw

Explaining compose variables content:

CONFIG_PROPERTIES_FILE_PATH\
• Description: full path to the settings file, including file name and extension\
• Example: ./home/run2biz/Documents/config.properties\

ATTACHMENTS_DIRECTORY\
• Description: directory used by citsmart/4biz to store files that are used as email
attachments\
• Example: /opt/attachments\
• Files: The files and sub-folders are deleted when the processing is finished.
IMAGE_GALLERY_DIRECTORY\
• Description: directory used by citsmart/4biz to store images that are used in
email construction\
• No need configuration! Will be automatically created inside the
ATTACHMENTS_DIRECTORY\
• Example: /opt/attachments/imageGallery\
• Files: The files are not deleted when the processing is finished. Because they
will be used again!

READ_FILE_DIRECTORY\
• Description: directory used by citsmart/4biz to store attachment files read to
send to SM project\
• No need configuration! Will be automatically created inside the
ATTACHMENTS_DIRECTORY\
• Example: /opt/attachments/readFile\
• Files: The files and sub-folders are deleted when the processing is finished.

Operation
Will Log
To aid in configuring Graph Mail, it recursively loops through and lists the folders found in the
mailbox:
[main] INFO br.com.mail.graph.thread.ThreadGraphMailReader - Existing folder:
XXXX

When the folders parameterized in the GRAPH MAIL FOLDERS LIST property are not found:
[br.com.mail.graph.thread.ThreadGraphMailReader] WARN
br.com.mail.graph.thread.ThreadGraphMailReader - Parameterized folders no found!

Means it will not read the emails


When found:
[main] INFO br.com.mail.graph.thread.ThreadGraphMailReader - Parameterized
folder: toRead Founded!

You might also like