Documentation ¶
Overview ¶
Package mail implements a parser for electronic mail messages as specified in RFC5322.
We allow both CRLF and LF to be used in the input, possibly mixed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Address ¶
interface to deal with an email address
func ParseAddress ¶
converts an array of bytes into an Address
type GroupAddr ¶
type GroupAddr struct {
// contains filtered or unexported fields
}
structure containing a list of recipients
type Header ¶
type Header struct {
Key, Value string
}
structure containing a header value (respecting RFC5322 or not)
type HeaderInfo ¶
type HeaderInfo struct { FullHeaders []Header // all headers OptHeaders []Header // unprocessed headers MessageId string Id string Date time.Time From []Address Sender Address ReplyTo []Address To []Address Cc []Address Bcc []Address Subject string Comments []string Keywords []string ContentType string InReply []string References []string }
structure containing the header vars as defined in RFC5322
type MailboxAddr ¶
type MailboxAddr struct {
// contains filtered or unexported fields
}
structure containing the email address parts
func (MailboxAddr) Name ¶
func (ma MailboxAddr) Name() string
returns a raw email address (eg "bruno.bluthgeld@mydomain.com")
func (MailboxAddr) String ¶
func (ma MailboxAddr) String() string
returns a complete email address (eg "Dr. Bloodmoney <bruno.bluthgeld@mydomain.com>")
type Message ¶
type Message struct { HeaderInfo Text string Body []byte Parts []Part }
structure containing a multipart message
func NewHTMLMessage ¶
returns a message with minimum headers and html content
func NewTextMessage ¶
returns a message with minimum headers and textual content
func Parse ¶
converts an array of bytes into a Message structure Successively calls ParseRaw() and Process()
func Process ¶
func Process(r RawMessage) (m Message, e error)
converts a RawMessage into a Message structure
type RawMessage ¶
structure containing a raw message (arrays of bytes)
func ParseRaw ¶
func ParseRaw(s []byte) (m RawMessage, e error)
converts an array of bytes into a RawMessage structure
type SMTPServer ¶
type SMTPServer struct { Host string Port uint16 Username string Password string From Address Auth *smtp.Auth }
structure to connect to a SMTP server
func InitGmail ¶
func InitGmail(fromAddress, loginAddress, password string) (*SMTPServer, error)
returns a server to a gmail account uses a different fromAddress for sending emails than the loginAddress used together with the password for authentication The fromAddress has to be verified as a valid sender address in Gmail.
func InitLocalHost ¶
func InitLocalHost(fromAddress string) (*SMTPServer, error)
returns the simplest possible server (localhost:25)
func (*SMTPServer) Close ¶
func (self *SMTPServer) Close() error
func (*SMTPServer) Name ¶
func (self *SMTPServer) Name() string
func (*SMTPServer) Send ¶
func (server *SMTPServer) Send(m *Message) error
sends a message via the SMTP server
type SMTPWriter ¶
implements io.Writer interface to use template.ExecuteTemplate()
Example:
body := new(mail.SMTPWriter) templates.ExecuteTemplate(body, "account_validation", boutique) message, err := mail.NewHTMLMessage(subject, body.String(), from, to) mailer.Send(message)
func (*SMTPWriter) String ¶
func (self *SMTPWriter) String() string