Documentation ¶
Index ¶
- Constants
- Variables
- func BmToEmail(bmAddr string) string
- func DisableLog()
- func GetContentType(contentType string) (content, subtype string, param map[string]string, err error)
- func GetSMTPBody(email *data.Content) (string, error)
- func ToBm(emailAddr string) (string, error)
- func UseIMAPLogger(logger btclog.Logger)
- func UseSMTPLogger(logger btclog.Logger)
- func ValidateEmail(to string) bool
- type Bmail
- type IMAPConfig
- type IMAPEmail
- func (e *IMAPEmail) AddFlags(newFlags types.Flags) mailstore.Message
- func (e *IMAPEmail) Body() string
- func (e *IMAPEmail) Flags() types.Flags
- func (e *IMAPEmail) Header() textproto.MIMEHeader
- func (e *IMAPEmail) InternalDate() time.Time
- func (e *IMAPEmail) Keywords() []string
- func (e *IMAPEmail) OverwriteFlags(newFlags types.Flags) mailstore.Message
- func (e *IMAPEmail) RemoveFlags(newFlags types.Flags) mailstore.Message
- func (e *IMAPEmail) Save() (mailstore.Message, error)
- func (e *IMAPEmail) SequenceNumber() uint32
- func (e *IMAPEmail) SetBody(body string) mailstore.Message
- func (e *IMAPEmail) SetHeaders(headers textproto.MIMEHeader) mailstore.Message
- func (e *IMAPEmail) Size() uint32
- func (e *IMAPEmail) UID() uint32
- type ImapData
- type Mailbox
- type MessageState
- type SMTPConfig
Constants ¶
const ( // DateFormat is the format for encoding dates. DateFormat = "Mon Jan 2 15:04:05 -0700 MST 2006" // Broadcast is the email address used to send broadcasts. Broadcast = "broadcast@bm.addr" )
Variables ¶
var ( // ErrInvalidEmail is the error returned by ToBM when the e-mail // address is invalid and a valid Bitmessage address cannot be extracted // from it. ErrInvalidEmail = fmt.Errorf("From address must be of the form %s.", emailRegexString) // ErrGetPubKeySent is the error returned by GenerateObject when a // a message could not be written as an object because the necessary // PubKey was missing. However, a GetPubKey request was successfully // sent, so we should receive it eventually. ErrGetPubKeySent = fmt.Errorf("GetPubKey request sent") // ErrAckMissing is the error returned by GenerateObject when a // message could not be written as an object because an ack is required // but missing. Therefore it is necessary to generate the ack and // do POW on it before proceeding. ErrAckMissing = fmt.Errorf("Ack missing") // BitmessageRegex is the regex of a Bitmessage address. BitmessageRegex = regexp.MustCompile(fmt.Sprintf("^%s$", bmAddrPattern)) // CommandRegex is used for detecting an email intended as a // command to bmagent. CommandRegex = regexp.MustCompile(commandRegexString) )
var ( IMAPLog btclog.Logger SMTPLog btclog.Logger )
Loggers initialized with no output filters. This means the package will not perform any logging by default until the caller requests it.
Functions ¶
func GetContentType ¶
func GetContentType(contentType string) (content, subtype string, param map[string]string, err error)
GetContentType takes a string representing the a Content-Type email header value and parses it into a set of values.
According to http://www.w3.org/Protocols/rfc1341/4_Content-Type.html, the proper format for Content-Type is given by
Content-Type := type "/" subtype *[";" parameter] type := "application" / "audio" / "image" / "message" / "multipart" / "text" / "video" / x-token x-token := <The two characters "X-" followed, with no intervening white space, by any token> subtype := token parameter := attribute "=" value attribute := token value := token / quoted-string token := 1*<any CHAR except SPACE, CTLs, or tspecials> tspecials := "(" / ")" / "<" / ">" / "@" ; Must be in / "," / ";" / ":" / "\" / <"> ; quoted-string, / "/" / "[" / "]" / "?" / "." ; to use within / "=" ; parameter values
func GetSMTPBody ¶
GetSMTPBody return the body of an e-mail to be delivered through SMTP.
func UseIMAPLogger ¶
UseIMAPLogger uses a specified Logger to output logging info for the IMAP server.
func UseSMTPLogger ¶
UseSMTPLogger uses a specified Logger to output logging info for the SMTP server.
func ValidateEmail ¶
ValidateEmail validates an email TO header entry.
Types ¶
type Bmail ¶
type Bmail struct { From string To string OfChannel bool // Whether the message was sent to/received from a channel. Expiration time.Time Ack []byte Content format.Encoding ImapData *ImapData State *MessageState }
Bmail represents an email compatible with a bitmessage format (msg or broadcast). If To is empty, then it is a broadcast.
func BroadcastRead ¶
BroadcastRead creates a Bitmessage object from an unencrypted wire.MsgBroadcast.
func NewBitmessageDraftFromSMTP ¶
NewBitmessageDraftFromSMTP takes an SMTP e-mail and turns it into a Bitmessage, but is less strict than NewBitmessageFromSMTP in how it checks the email.
func NewBitmessageFromSMTP ¶
NewBitmessageFromSMTP takes an SMTP e-mail and turns it into a Bitmessage.
type IMAPConfig ¶
IMAPConfig contains configuration options for the IMAP server.
type IMAPEmail ¶
type IMAPEmail struct { ImapSequenceNumber uint32 ImapUID uint64 ImapFlags types.Flags Date time.Time Mailbox Mailbox Content *data.Content }
IMAPEmail is a representaton of an email that is compatible with the IMAP protocol and is an implementation of mailstore.Message. An email according IMAP is associated with a particular mailbox and therefore includes things like a uid and sequence number.
func (*IMAPEmail) AddFlags ¶
AddFlags writes the flags for this message and return the updated message.
func (*IMAPEmail) Header ¶
func (e *IMAPEmail) Header() textproto.MIMEHeader
Header returns the message's MIME headers as a map in a format compatible with imap-server.
func (*IMAPEmail) InternalDate ¶
InternalDate return the date the email was received by the server (This is not the date on the envelope of the email).
func (*IMAPEmail) OverwriteFlags ¶
OverwriteFlags overwrites the flags for this message and return the updated message.
func (*IMAPEmail) RemoveFlags ¶
RemoveFlags writes the flags for this message and return the updated message.
func (*IMAPEmail) SequenceNumber ¶
SequenceNumber returns the sequence number of the email.
func (*IMAPEmail) SetHeaders ¶
func (e *IMAPEmail) SetHeaders(headers textproto.MIMEHeader) mailstore.Message
SetHeaders sets the headers of a message.
type ImapData ¶
type ImapData struct { UID uint64 SequenceNumber uint32 Flags types.Flags TimeReceived time.Time Mailbox Mailbox }
ImapData provides a Bitmessage with extra information to make it compatible with imap.
type Mailbox ¶
type Mailbox interface { mailstore.Mailbox // Save saves an IMAP email in the Mailbox. Save(email *IMAPEmail) error // AddNew adds a new Bitmessage to the Mailbox. AddNew(bmsg *Bmail, flags types.Flags) error // DeleteBitmessageByUID deletes a bitmessage by uid. DeleteBitmessageByUID(id uint64) error }
Mailbox represent a mailbox compatible with both IMAP and Bitmessage.
type MessageState ¶
type MessageState struct { // Whether a pubkey request is pending for this message. PubkeyRequestOutstanding bool // The number of times that the message was sent. SendTries uint32 // The last send attempt for the message. LastSend time.Time // Whether an ack is expected for this message. AckExpected bool // Whether an ack has been received. AckReceived bool // Whether the message was received over the bitmessage network. Received bool }
MessageState contains the state of the message as maintained by bmclient.
type SMTPConfig ¶
SMTPConfig contains configuration options for the SMTP server.