ezmail

package module
v0.0.0-...-3cb152a Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2013 License: MIT Imports: 4 Imported by: 0

README

ezmail

A library to create mail messages and ease golang net/smtp package usage.

Usage

Here is how to use this package to send a basic mail message.

msg := ezmail.Message{}
msg.SetFrom("Marc Weistroff", "marc@example.org")
msg.AddTo("Recipient 1", "recipient1@example.org")
msg.AddTo("", "foobar@example.org")
msg.AddCC("", "cc@example.org")
msg.Subject = "Hey, message subject"
msg.Body = "plain text body"
smtp.SendMail(addr, auth, msg.From.String(), msg.Recipients(), msg.Bytes())

Edge Cases

When sending emails through GMail SMTP servers, if you run into an error like:

555 5.5.2 Syntax error. z6sm27198953bkn.8 - gsmtp

Try changing the smtp.SendMail call in order to provide only the email addresses (without full names)

smtp.SendMail(addr, auth, msg.From.Address, msg.RecipientsEmails(), msg.Bytes())

License

The ezmail code is free to use and distribute, under the MIT license.

Build Status

Documentation

Overview

package ezmail implements basic mail creation to ease the net/smtp package use

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	From        mail.Address
	To, Cc, Bcc []mail.Address

	Subject string
	Body    string
}

A Message represents an electronic message Usage: msg := ezmail.Message{} msg.SetFrom("Marc Weistroff", "marc@example.org") msg.AddTo("Recipient 1", "recipient1@example.org") msg.AddTo("", "foobar@example.org") msg.AddCC("", "cc@example.org") msg.Subject = "Hey, message subject" msg.Body = "plain text body" smtp.SendMail(addr, auth, msg.From.String(), msg.Recipients(), msg.Bytes())

func NewMessage

func NewMessage() *Message

func (*Message) AddBcc

func (msg *Message) AddBcc(name, email string)

func (*Message) AddCc

func (msg *Message) AddCc(name, email string)

func (*Message) AddTo

func (msg *Message) AddTo(name, email string)

func (*Message) Bytes

func (msg *Message) Bytes() []byte

Bytes returns the []byte representation of the message

func (*Message) Recipients

func (msg *Message) Recipients() []string

Returns list of recipients (Format: "Recipient Name <recipientemail@example.com>")

func (*Message) RecipientsEmails

func (msg *Message) RecipientsEmails() []string

Returns list of recipient email addresses

func (*Message) SetFrom

func (msg *Message) SetFrom(name, email string)

func (*Message) String

func (msg *Message) String() string

String returns the string representation of the message

Jump to

Keyboard shortcuts

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