imap-discovery

module
v0.0.0-...-eb0ccd6 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: Apache-2.0

README

IMAP Discovery

A library to help 'discover' IMAP connection parameters. IMAP is hard, and it's hard to know how to connect to a given email service provider.

Some providers, like Gmail, have well-known connection parameters. Others may choose to publish connection parameters via self-hosted XML documents, or publishing them to Mozilla Thunderbird Autoconfiguration project. There may also be MX records to check!

This library checks all these sources and either gives you all the successful results, or the one that we believe is the most likely to succeed.

Our recommended order, and the one checked by the main library entrypoint, DiscoverImapConfig, is:

  • Known Domains
  • Autoconfig documents hosted by the domain
  • Mozilla's autoconfig service
  • MX records for the domain

Usage

// Get one config
config, err := discovery.DiscoverImapConfig("[email protected]")

// Check all possible options
configs, err := discovery.DiscoverAllImapConfigs("[email protected]")

// Check a specific method
// note the email split in the specific methods
config, err = GetMozillaAutoConfig("email", "example.com)

Response shape

// Config represents the IMAP Config response from this service
type Config struct {
	Email         string              `json:"email"`
	Username      string              `json:"username"`
	Provider      string              `json:"provider"`
	Server        string              `json:"server"`
	Port          int                 `json:"port"`
	SSL           bool                `json:"ssl"`
	OAuth         bool                `json:"oauth"`
	Documentation []ImapDocumentation `json:"documentation"`
}

// ImapDocumentation represents provided documentation
type ImapDocumentation struct {
	URL         string `json:"url"`
	Description string `json:"description"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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