Managing Emails
Setting up Outbound Emails
To send outgoing emails from the system, turn on your mail server by editing framework/common/config/general.properties and setting mail.notifications.enabled=Y. You can also configure a special SMTP host, user, and password here.
Processing Inbound Emails
To process inbound e-mails with opentaps, we recommend that you set up your mail server so that all your incoming e-mails are automatically forwarded to an e-mail address with their original TO and CC intact. Opentaps can then be set up to listen to that e-mail address and process them.
For example, fetchmail can relay messages from an POP/IMAP server such as dovecot to a postfix SMTP server. Here is an example for configuring your /home/opentapsmail/.fetchmailrc to relay the e-mails to a user on your server called opentapsmail:
# for test and not delete emails from the server you can add at the end of each line # keep # to log in the system logs just add at the beginning of the file # set syslog poll mail.mydomain.com proto pop3 user joe there with password 12345 is opentapsmail here poll mail.mydomain.com proto pop3 user jane there with password 55645 is opentapsmail here
For more information, see configuring fetchmail.
opentaps can then listen on the opentapsmail email address of your server. To set this up, edit framework/base/config/ofbiz-containers.xml and set “mail.host”, “mail.user”, “mail.pass” for “javamail-container” to your server. Both IMAP and POP3 are supported for “mail.store.protocol”. If you set “delete-mail” to true, then the messages will be deleted after they are retrieved, even if they do not match any of the MCA conditions. If you set “delete-mail” to false, then messages will be marked “seen.” If you have an IMAP server, then they won’t be downloaded the next time. If you have a POP3 server, however, “seen” is not supported, so if the messages are not deleted, they will be downloaded over and over again. Finally, the "maxSize" property is used to control the largest size of emails received. You should set it to a larger value than the default of 100000 (100 KB).
Once you have set up your listener, you need to set up a processing service for your incoming emails. This can be set up by configuring an MCA or Mail-Condition-Action in any of your applications. By default, the opentaps CRMSFA application has MCA configured to process both incoming emails and outgoing emails which are being BCC'd to a mailbox for opentaps to archive. An MCA can be configured by adding the following to your ofbiz-component.xml:
<service-resource type="mca" loader="main" location="servicedef/smcas.xml"/>
The smcas.xml file should have a definition of how to process the incoming email, such as the following from CRMSFA:
<mca mail-rule-name="processIncomingEmail"> <condition-field field-name="to" operator="matches" value=".*@opentaps\.org>*"/> <action service="crmsfa.processIncomingEmail" mode="sync"/> </mca>
Note that regular expressions can be used to identify which emails should be processed by which MCA. The MCA invokes a service which must implement the mailProcessInterface to process emails. The service will be given a MimeMessageWrapper to process emails with. For more information about the default email processing in opentaps, see Handling Emails.