imapsync

package module
v0.0.0-...-6ef4252 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2018 License: Apache-2.0 Imports: 10 Imported by: 2

README

GoDoc Build Status Go Report Card

go-imap-sync

Library and command-line tool to sync the contents of an IMAP folder to disk, using https://github.com/emersion/go-imap.

What does it do?

imapsync downloads all emails from an IMAP mailbox, each email into a plain text file. The names of the files are derived from the email message ID. This enables imapsync to avoid downloading emails twice.

Usage from the Command Line

go get github.com/JohannesEbke/go-imap-sync/cmd/go-imap-sync
go-imap-sync -server mail.example.com:993 -username me -mailbox INBOX

You will be prompted for your password. If you use the program in scripts, you can also set the IMAP_PASSWORD environment variable.

Usage as a Library

err := imapsync.Sync("mail.example.com:993", "me", "hunter2", "INBOX", "/home/me/mails")

Why?

I've encountered the problem of acquiring incoming email from IMAP now in two different projects, https://github.com/martinhoefling/go-dmarc-report and https://github.com/TNG/openpgp-validation-server, and decided to factor out the common parts.

Roadmap

One possible additional mode of operation is to continuously monitor an IMAP mailbox, download new mails as they appear and notify the caller of the new emails, e.g. via a channel.

Documentation

Overview

Package imapsync provides a single function to download an IMAP folder to a local directory, with each email in a plain text file. Emails are downloaded only once, even if the function is run repeatedly.

A command line tool is available at https://github.com/JohannesEbke/go-imap-sync/cmd/go-imap-sync

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	ExistingEmails []string
	NewEmails      []string
}

Result contains slices of (relative) paths to the newly (NewEmails) and previously downloaded emails (ExistingEmails). Only emails still present on the server will be returned.

func Sync

func Sync(server, user, password, mailbox, emailDir string) (*Result, error)

Sync downloads and saves all not-yet downloaded emails from the mailbox to the emailDir

Directories

Path Synopsis
cmd
go-imap-sync
go-imap-sync provides a simple command line tool to download emails from an IMAP mailbox.
go-imap-sync provides a simple command line tool to download emails from an IMAP mailbox.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL