Skip to content

EmailWorker

Michiel TJampens edited this page May 11, 2021 · 2 revisions

Introduction

Purpose

Allow emails to be send via SMTP and/or connect to an IMAP server.

Main features

  • Send/Receive emails with attachments via IMAP
  • Act as a source
  • Allow the user to control dcafs

Reference guide

Setup

  1. Use the command email:addblank to add the following section to the settings.xml (without the additional comments).
    These need to be altered to match the server used.

Note: You don't need to define both. If no email need to be received, just delete that node. For now, dcafs needs to be restarted.

    <email>
      <!-- Settings related to sending -->
      <outbox> 
        <server pass="" port="993" ssl="yes" user="">host/ip</server>
        <from>das@email.com</from> <!-- The email address that will show up in the 'from' field -->
        <zip_from_size_mb>3</zip_from_size_mb> <!-- Attachments larger than this size will be zipped -->
        <delete_rec_zip>yes</delete_rec_zip> <!-- If a received zip should be deleted after unpacking -->
        <max_size_mb>10</max_size_mb> <!-- Zipped files larger than this amount WONT be send -->
      </outbox>
      <!-- Settings for receiving emails -->
      <inbox>
        <server pass="" port="465" ssl="yes" user="">host/ip</server>
        <checkinterval>5m</checkinterval> <!-- How often should the worker check for new emails -->
          <!-- If an email was received, the interval will temporary decrease to about a third of what was set -->
          <!-- this is done to quicker reply to follow ups -->
      </inbox>
      <!-- Add entries to the emailbook below -->
      <book> <!-- This is a list of known contact for the instance, only emails mentioned here can issue commands -->
         <entry ref="admin">admin@email.com,anotheradmin@email.com</entry>
         <entry ref="scientist">user@email.com</entry>
      </book>
    </email>
  1. To enable the altered blank send email:reload

Commands

Send email:? to get the available commands

  • email:reload Reload the settings found in te XML.
  • email:refs Get a list of refs and emailadresses.
  • email:send,to,subject,content Send an email using to with subject and content
  • email:setup Get a listing of all the settings.
  • email:checknow Checks the inbox for new emails
  • email:addallow,from,cmd(,isRegex) Adds permit allow node, default no regex
  • email:adddeny,from,cmd(,isRegex) Adds permit deny node, default no regex
  • email:interval,x Change the inbox check interval to x (fe. 5m or 60s or 1h etc)

Additional functionality

Permissions

Defaults

  1. Any time any (non-admin) user sends a command to the instance the admin will be informed (if outbox is set)
  2. Any time an email is received from an unknown address, the admin is informed, and the sender gets a reply.
  3. Email addresses can have an alias using | as separator, this is only relevant for the admin (if using two distinct addresses) so that the address isn't considered spam nor considered from a non-admin user (in respect to the earlier two points)
  4. By default, all registered addresses can use all commands except those that are considered 'admin' commands. Those are only available to the ones registered as admins
    • sd:reason shuts down the instance
    • admin: Any command that starts with admin
    • retrieve Any command that starts with retrieve (allows retrieving scripts)
    • update Any command that starts with update (allows updating scripts)
    • sleep Puts the instance to sleep (in linux)

Add/Remove

  • To add a permission use email:addallow,from,cmd(,isRegex)
    • Example: allow 'superuser' to use admin commands: email:addallow,superuser,admin:.*,true
  • To deny a user the use of a certain command email:adddeny,from,cmd(,isRegex)
    • Example: deny 'superuser' to add anything: email:adddeny,superuser,.*:add.*,true
Clone this wiki locally