Skip to content
An R Interface to IMAP
R Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
inst
man
tests
.Rbuildignore
.gitignore
.travis.yml
DESCRIPTION
LICENSE
NAMESPACE
NEWS.md
README.md
README.rmd
imapr.Rproj

README.md

imapr - An R Interface to IMAP

imapr performs IMAP queries via curl.

Builds

master

Travis-CI Build Status

develop

Travis-CI Build Status

Installation

require("devtools")

install_github("crazycapivara/imapr")

Usage

library(imapr)

host <- "imaps://imap.gmail.com"

imap <- IMAP(host) %>% user("your_username", "your_password")
imap[c("url", "path")]
## $url
## [1] "imaps://imap.gmail.com"
## 
## $path
## [1] ""

List and select mailboxes

response <- imap %>% LIST() %>% execute()
response %>% cat()
## * LIST (\HasNoChildren) "/" "INBOX"
## * LIST (\HasChildren \Noselect) "/" "[Gmail]"
## * LIST (\All \HasNoChildren) "/" "[Gmail]/Alle Nachrichten"
## * LIST (\Drafts \HasNoChildren) "/" "[Gmail]/Entw&APw-rfe"
## * LIST (\HasNoChildren \Sent) "/" "[Gmail]/Gesendet"
## * LIST (\Flagged \HasNoChildren) "/" "[Gmail]/Markiert"
## * LIST (\HasNoChildren \Trash) "/" "[Gmail]/Papierkorb"
## * LIST (\HasNoChildren \Junk) "/" "[Gmail]/Spam"
## * LIST (\HasNoChildren \Important) "/" "[Gmail]/Wichtig"
imap %>% SELECT("INBOX") %>% .[c("url", "path")]
## $url
## [1] "imaps://imap.gmail.com"
## 
## $path
## [1] "INBOX"

Search for messages

search_all <- imap %>% SELECT("INBOX")
   %>% SEARCH("ALL") %>% execute() 
search_all %>% substr(1, 20)
## [1] "* SEARCH 1 2 3 4 5 6"
## attr(,"url")
## [1] "imaps://imap.gmail.com/INBOX"

Fetch messages

header <- imap %>% SELECT("INBOX") %>%
  FETCH(1, sections("header_min")) %>% execute()
header %>% cat()
## From: Travis CI <builds@stuff.hi>
## Subject: Failed: crazycapivara/owmr#35 (bleeding-edge - fd15c7d)
## To: <coughing@cohen.salut>
## Date: Sat, 17 Dec 2016 14:39:40 +0000
## 
## To be continued ##

Run tests

devtools::test(reporter = "tap")
## Loading imapr

## Loading required package: testthat

## Testing imapr

## 1..5
## # Context imap
## ok 1 init
## ok 2 init
## # Context SEARCH
## ok 3 by flags
## ok 4 by flags
## # Context SELECT
## ok 5 escape mailbox name with brackets
You can’t perform that action at this time.