Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IMAP Email Driver
#1
Hey all,
   Got stuck in an airport for a disgusting amount of time this week, so I decided to to push forward on a project from the checklist. I could have gotten there faster by mule....possibly. Anyways, so without (any more) delay, I'd like to announce the IMAP Email driver. Really exciting, I know. Actually surprised no one has done it before now, but wuench's driver has done it for me (and likely many others) until now.

I won't explain the differences between POP3 and IMAP, that's up to you to explore.Wink

Be sure to read below on what is currently working and what is still in development......

// Version 1.0 - (Beta)    June  2017
//
//   Initial release, built for IMAPv4, RFC 3501
//      -- Designed to parallel wuench's POP3 driver in functionality
//
//      -- Connects to a single IMAP mailbox, provides fields for total and unread email counts
//      -- Processes any unread emails, imports subject/date/from into field lists
//      -- Updates custom fields based on properly formatted command(s) in text body of email
//
//  IMAP Design Notes:
//      -- IMAP protocol can support multiple commands simultaneously, but try to keep all ops serial
//      -- IMAP updates (new messages info or flag changes) will be transmitted at any time by server, even during other ops
//      -- While a active operation semaphor could be implemented, it has not to allow for flexibility (for now?)
//      -- After inital login and mailbox selection, SEARCH command is performed to request latest unread email(s)
//      -- Each new email is fetched and parsed for custom field commands        
//      -- Only essential IMAP protocol support, does not support attachments
//
//  Working:
//      -- Initial connection, login
//      -- Poll frequency alteration,
//      -- Debug mode >> dumps detailed data to log file
//      -- Mailbox connection and counts (total/unread) updates
//      -- Diagnostic fields: Server IP, driver version fields, last Poll success duration/time,
//      -- IMAP server 'Capability' response field
//      -- Reads params from config file
//      -- Creates any fields defined in config file for email parsing output
//      -- Downloads message bodies, parses them for output and/or Authentication string
//
//  InTest:
//      -- Accepts Auth and/or custom field change command(s) on same/multiple lines
//      -- Header, Date, Subject list >> updates after new email
//      -- Verify can update all field types -- String, Card, Int, Float, and Boolean
//      -- GetMail - manual email download (debug/testing expected usage only)
//      -- Delete command emails when enabled
//      -- Should handle ANY number of field triggers, depending on system memory and field name uniqueness
//      -- New email(s) fetch/process upon notify
//
//  InWork:
//      -- Retains email processing to avoid work duplication upon reconnection - cache to local file
//
// Usage:
//      -- WARNING: Use sTunnel (or alternative) for network security
//      -- Polling interval is field/user configurable
//      -- Auth tokens should be included in body text BEFORE any field change commands
//      -- Enable of 'DeleteCommandEmails' is recommended to avoid repeated field value change action



Here is the contents of sample config file the driver needs:

###############        CONFIG FILE - for CQC IMAP Device Driver        ###############
####
#### ---- One config item per line, Use '~' for seperator. Lines with '#' will be ignored. ---- ####
####
UserName~someone@nowhere.com
Password~SecurePassword

# How often do we verify connection is still alive and process new emails?
PollInterval~30000

# Enable for command parsing of email body text
CommandEnable~True

# Authenication string that must be included for command emails, use blank to disable
CommandAuthToken~SomeStringThatShouldNeverExist-MaybeUseSomethingMoreComplex?JustDon'tUsetheSepChar!

# Enable for deletion of any emails that contained parsed commands
DeleteCommandEmails~True

#
# Add additional custom fields on seperate lines
CustomField~CheckTestField~String

# DebugEnable will dump debugging and detailed logging to a local file in MacroFileRoot
DebugEnable~False
# Not sure if this will be required to be changed for others, it wasn't for my needs
MailboxName~INBOX


Clearly there is still more development to perform, but I would say 'Medium' confidence in stability and release level.

Please leave a post just to let me know you are using the driver. Thanks!


Attached Files
.cqcdrvpack   IMAP-v1-0.2017.06.05.CQCDrvPack (Size: 21.92 KB / Downloads: 2)
Reply
#2
Let me know if there's any underlying functionality that is missing to get it done.
Dean Roddey
Explorans limites defectum
Reply
#3
(05-27-2017, 08:12 PM)whozeawhat Wrote: Hey all,
   Got stuck in an airport for a disgusting amount of time this week, so I decided to to push forward on a project from the checklist. I could have gotten there faster by mule....possibly. Anyways, so without (any more) delay, I'd like to announce a future IMAP Email driver. Really exciting, I know. Actually surprised no one has done it before now, but wuench's driver has done it for me (and likely many others) until now.

-- I'll attach a beta version of driver in the next week, or so, after I find a few more bugs myself. Here's my notes so far, please feel free to chime in and give your thoughts/ideas.



//   Initial release, built for IMAPv4, RFC 3501
//      -- Designed to parallel wuench's POP3 driver in current planned functionality
//
//      -- Connects to a single IMAP mailbox, provides fields for total and unread email counts         
//      -- Only essential IMAP protocol support, does not support attachments (is this desired?)
//
//  Working:
//      -- Initial connection, login
//      -- Poll frequency alteration,
//      -- Debug mode >> dumps detailed data to log file
//      -- Mailbox connection and counts (total/unread) updates
//      -- Diagnostic fields: Server IP, driver version fields, last Poll success duration/time,
//      -- IMAP server 'Capability' response field
//
//  ToDo:
//      -- Reads params from config file
//      -- Creates any fields defined in config file for email parsing output
//      -- Downloads message bodies, parses them for output and/or Authentication string
//      -- Tracks email processing to avoid work duplication
//      -- Header & Subject Lists ( for latest 10 messages ?)

FWIW, I could see attachments being desired; i.e. send me a copy of some set of parameters stored in a file at a predefined frequency.  I don't know that I'd use it, but I could see it being requested by those that log things.
Flamin' Noobie...
Warp speed now and don't give me any of that dilythium crystal crap!
Reply
#4
if i understand correctly, this still requires stunnel to talk to gmail?

greg
Reply
#5
I would think so. CML doesn't have access to our secure sockets functionality, other than for HTTP.
Dean Roddey
Explorans limites defectum
Reply
#6
i have beat my head against stunnel for some time. Never have gotten it to work. wish there was a simpler solution.

the pop3 driver fails repeatedly and stunnel shows this sequence over and over.

2017.06.13 21:35:18 LOG5[145]: Service [gmail-pop3] accepted connection from 192.186.1.103:58459
2017.06.13 21:35:18 LOG5[145]: s_connect: connected 74.125.202.108:995
2017.06.13 21:35:18 LOG5[145]: Service [gmail-pop3] connected remote server from 192.186.1.103:58460
2017.06.13 21:35:18 LOG5[145]: Connection closed: 65 byte(s) sent to TLS, 4461 byte(s) sent to socket
Reply
#7
Are you using an assigned application account associated with your gmail account or your user name for your stunnel config? I stopped using stunnel when Dean added gmail capability to CQC but when I did I did not have any issues setting it up on Windows
Reply
#8
i am not sure what an assigned application account is.  googled it and didnt see much.  i have an account that i created in gmail just for this project.  i enabled pop3 and set up the pop3 driver to point to localhost and port 5000.  i then installed stunnel with these settings:

; ***************************************** Example TLS client mode services

[gmail-pop3]
client = yes
accept = 5000
connect = pop.gmail.com:995
verifyChain = yes
CAfile = ca-certs.pem
checkHost = pop.gmail.com
OCSPaia = yes
Reply
#9
(06-14-2017, 06:12 AM)batwater Wrote: Are you using an assigned application account associated with your gmail account or your user name for your stunnel config?  I stopped using stunnel when Dean added gmail capability to CQC but when I did I did not have any issues setting it up on Windows

In this case, he's not sending e-mails via CQC, he's using a driver that pulls down e-mails.
Dean Roddey
Explorans limites defectum
Reply
#10
got it working. i replaced localhost with the machines ip address and it worked. makes no sense but i'll take it.

greg
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  New Driver - How hard would this be? kblagron 4 504 05-20-2019, 11:28 AM
Last Post: zaccari
  Cytech Comfort Driver znelbok 6 476 04-10-2019, 05:39 PM
Last Post: znelbok
  OpenHAB Driver whozeawhat 6 2,320 01-16-2019, 06:45 AM
Last Post: greymatter
  LIFX Driver bobskie708 14 3,907 01-10-2019, 06:36 PM
Last Post: Dean Roddey
  XBMC Driver wuench 428 185,610 12-28-2018, 11:07 AM
Last Post: dogman
  Amazon Echo Hue Simulator Driver wuench 117 49,664 12-24-2018, 11:10 AM
Last Post: Dean Roddey
  RunTimer2 driver rbroders 15 5,584 12-14-2018, 05:28 PM
Last Post: rbroders
  Driver for Bigass Fan lleo 7 924 11-25-2018, 08:57 AM
Last Post: Dean Roddey
  Generic Modbus Driver - Serial & IP znelbok 25 14,519 10-09-2018, 08:59 AM
Last Post: Ron Haley
  Issues debugging IP based driver jnolting 5 1,269 09-24-2018, 11:52 AM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)