InstallationManual/SetupMailgate
From Wiki
Contents |
[edit] What is Mailgate
Mailgate is a Python script which can process incoming emails and create a CRM case from the email.
[edit] Mailgate Installation
Mailgate is provided with the Tiny distribution and included with the CRM module. You can find the script here:
<server install directory>/bin/addons/crm/scripts/tinyerp-mailgate/tinyerp-mailgate.py
[edit] Mailgate setup
Mailgate is an MDA (Mail Delivery Agent) and can manage messages sent to it from another MDA or an MTA (Mail Transfer Agent). It has very basic mail handling functions, so logic for managing valid domains / addresses / junk mail blocking, etc should be managed within the MTA
[edit] Mailgate command line options:
"--version", "show program's version number and exit" "-h", "--help", "show help message and exit" "-u", "--user", "ID of the user in OpenERP", default=3 "-p", "--password","Password of the user in OpenERP", default='admin' "-e", "--email","Email address used in the From field of outgoing messages" "-s", "--section","ID or code of the case section", default="support" "-m", "--default","Default eMail in case of any trouble." "-d", "--dbname", "Database name (default: terp)"
[edit] CRM Section Setup
Ensure you create an entry in the "code" of a section and specifiy this code as the section on the command line with the -s flag.
[edit] Mailgate with Linux MTA
[edit] Fetchmail
The program fetchmail is a 3rd party program to fetch mail from a POP, IMAP, ETRN, or ODMR-capable server. It can be found at http://fetchmail.berlios.de/. On debian it can be installed as
apt-get install fetchmail
One downloaded and installed, you need to configure fetchmails' parameters. These can be found in the file addons/crm/scripts/tinyerp-mailgate/fetchmailrc an example is given, and for another example, these are my settings:
poll mail.mydomain.net proto pop3 port 995 : username "helpdesk" password "mypw" mda "/home/terp/addons/crm/scripts/tinyerp-mailgate/tinyerp-mailgate.py -u 3 -p admin -s SECEMAIL -e me@mydomain.com -m me@mydomain.com -d mydb"
Following this format:
poll <your pop server name proto pop3: username <pop3 username> password <pop3 Password> mda "<path to Mailgate>/tinyerp-mailgate.py -u<Tiny User ID> -p<Tiny User Password> -s<Tiny case section> -e<sender email> -d<Fallback Email Address>"
Note: to see the list of all parameters for the tinyerp-mailgate program, type ./tinyerp-mailgate.py --help in the addons/crm/scripts/tinyerp-mailgate directory.
Note: if you are using a port other than the default port of 8069, you will need to add your port number directly into the file tinyerp-mailgate.py
Note: if you are using a secure connection for OpenERP, you will need to edit the file tinyerp-mailgate.py and change the word http for https.
Once your fetchmailrc file is setup, you can test it by first sending an email to your helpdesk - in my case this is helpdesk@mydomain.com. Then run fetchmail, giving it your fetchmailrc as a parameter ie. fetchmail --ssl -f ./fetchmailrc This assumes that you are in the directory addons/crm/scripts/tinyerp-mailgate.
And you should have output similar to:
reading message helpdesk@www.mydomain.com:1 of 2 (1555 octets).* Email parser test402 3 admin Section ID 4 -.- ICI Mail Sent to test402 3 admin test402 3 admin Case 36 created... test402 3 admin [] flushed reading message helpdesk@www.mydomain.com:2 of 2 (1534 octets).* Email parser test402 3 admin Section ID 4 -.- ICI Mail Sent to test402 3 admin test402 3 admin Case 37 created... test402 3 admin [] flushed
[edit] Sendmail
TODO
[edit] Procmail
TODO
[edit] Troubleshooting
[edit] Ubuntu 6.06 + Tiny 4.0.3
Use the 4.1.1 mailgate by downloading the source and copying the file /tinyerp-server-4.1.1/bin/addons/crm/scripts/tinyerp-mailgate/tinyerp-mailgate.py to /tinyerp-server-4.0.3/bin/addons/crm/scripts/tinyerp-mailgate/tinyerp-mailgate4.1.1.py Then modify line 130 of tinyerp-mailgate4.1.1.py to read as follows(notice the #):
message['body'] += part.get_payload(decode=True)#.decode(part.get_charsets()[0])
Finally you can use the following in your fetchmailrc:
poll pop.secureserver.net proto pop3: username mypop3username password mypop3password mda "/tinyerp-server-4.0.3/bin/addons/crm/scripts/tinyerp-mailgate/tinyerp-mailgate4.1.1.py -u3 -pmytinypassword -ssupport -emyemailaddress -mmyemailaddress -dmydatabase"

