Most Powerful Open Source ERP

How To Use CMFMailIn Tool

How To showing how to receive mail messages and passing them into ERP5.
  • Last Update:2016-02-09
  • Version:001
  • Language:en

The Mail In Tool allows receiving mail messages from the outside source and passing them into Zope and ERP5 Site.

Table of Contents

How to enable and configure the CMF MailIn Tool

To make the Tool work you need to add it to ERP5 Site. It's included among other tools. After adding it, in the Configure tab of the Tool you need to specify the name of the script which will process the received mail messages. You can click the 'Setup the Skins for Mail_In Tool' button, but then you have to create the 'mailin' skin folder manually. Alternatively you might NOT click that button and put the processing script in any custom skin folder as long as it's included in the Skin Layers. The script that will be created has to have one parameter eg. 'Mail' which will be passed to it by the Tool and it will contain the dictionary with all the email content.

How to use the MailIn Tool

For testing purposes it's possible to pipe the mail messages (saved as files) to Zope 'by hand'. The postMailToERP5 script handles the delivery of the mail message to ERP5. It's located in $INSTANCE_HOME/Products/ERP5/bin directory. We can send the mail by manually calling the postMailToERP5 script with appropriate address. For example like that:

cat mail_message.eml | python postMailToERP5 http://zope:zope@localhost:9080/erp5/portal_mailin

where:

  • 'mail_message.eml' is the saved email
  • 'zope:zope' is the user and password of the manager user in Zope
  • 'localhost:9080' is the example of machine/port on which Zope runs

As mentioned above 'Mail' parameter is a dictionary. It contains following keys:

  • 'body' : which value is basically the email body :)
  • 'attachements' : which value is a list of tuples -> (attachement_(file)name, attachement_content_type, attachement_body)
  • 'headers' : which value is a dictionary of all email headers (like to:, from:, subject:, etc.)

The body and headers are all recoded to 'utf-8' so should be readable and ready-to-use.

Mail server configuration

Postfix

Create an alias in /etc/postfix/aliases (or in /etc/aliases, depends on the postfix configuration) an alias which would look like this:

crm:"|/[path]/sendMailToERP5.py http://[login]:[passwd]@[host]:[port]/erp5/portal_mailin"

or even better like this:

crm:"|/[path]/sendMailToLocalProject.py"

where above script 'sendMailToLocalProject.py' calls the sendMailToERP5.py script passing login and password. Since password has to be given here in plain, in above way it won't get displayed/logged in case of any error.

Then run command:

newaliases

(restarting postfix is not enough, and actually not needed).

Related Articles