Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Mail Receiver

German Escobar edited this page Jun 19, 2013 · 5 revisions

A connector that receives Email messages through IMAP or IMAPS.

XML Configuration Example

The following is a simple XML configuration of the Mail Receiver for GMail that you would add to applications.xml or connections.xml:

<connector id="mail-test" className="org.mokai.connector.mail.MailReceiver">
    <configuration>
        <property name="host">imap.gmail.com</property>
        <property name="tls">true</property>
        <property name="username">[email protected]</property>
        <property name="password">p4ssword</property>
    </configuration>
</connector>

Configuration options

Property Default Description
host localhost The IP or host name of the email server.
tls false true of false. Use TLS?
port -1 The port in which the email server is listening. -1 to use the default port.
username The username used to authenticate.
password The password used to authenticate.
folder INBOX The folder to fetch from.
reconnectDelay 5000 If the connection fails, wait for the specified time before trying to reconnect.
unseen true Only process unseen messages.
delete true Delete processed messages.

Email to SMS

The most common use case of receiving an Email is to convert it to an SMS message. This is why I have included a built-in solution in this connector.

Currently there are two options that you can choose in the configuration:

  1. Use the subject of the email as the mobile number (the body of the email will become the text of the SMS).
  2. Send all messages to a fixed mobile number (the subject will be included in the email).

Use subject as mobile number

<connector id="mail-test" className="org.mokai.connector.mail.MailReceiver">
    <configuration>
        <!-- see above, not included for brevity -->
    </configuration>
   
    <post-receiving-actions>
        <action className="org.mokai.action.mail.EmailToSmsAction">
             <property name="useSubjectAsTo">true</property>
             <property name="smsFrom">3768</property>
        </action>
    </post-receiving-actions>
</connector>

Fixed mobile number

<connector id="mail-test" className="org.mokai.connector.mail.MailReceiver">
    <configuration>
        <!-- see above, not included for brevity -->
    </configuration>
   
    <post-receiving-actions>
        <action className="org.mokai.action.mail.EmailToSmsAction">
             <property name="smsTo">13201111111</property>
             <property name="smsFrom">1234</property>
        </action>
    </post-receiving-actions>
</connector>

Configuration Options

Property Default Description
useSubjectAsTo false Use the subject of the email as the mobile number. The property `smsTo` must not be present.
smsTo Use a fixed mobile number where all the messages are sent. The property "useSubjectAsTo" must not be present of must be set to false.
smsFrom 12345 The string that will be set in the "from" property of the message
textLength 160 The max length to allow. If the message is longer, it will be cut.

Clone this wiki locally