gsender

package module
v0.0.0-...-bde8818 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2015 License: MIT Imports: 15 Imported by: 0

README

gsender

a smtp sender written by golang

##install

go get github.com/voids/gsender

	import (
    	"github.com/voids/gsender"
    )

##demo

	sender := new(gsender.Sender)
	sender.Address = "voids@example.com"
	sender.Name = "voids"
	sender.Password = "********"
	sender.Host = "smtp.example.com"
	sender.Port = 25
	// sender.TLS = true

	msg := new(gsender.Message)
	// msg.Html = true
	msg.SetSubject("A test email")
	msg.SetBody("this is a test email which sent by golang.")
	if err := msg.AddAttachment(`/home/voids/pic.jpg`); err != nil {
		panic(err)
	}

	receiver := new(gsender.Receiver)
	receiver.AddTo("John", "John@example.com")
	receiver.AddTo("Lily", "Lily@example.com")
	receiver.AddCc("Dog", "dog@example.com")
	receiver.AddBcc("hacker", "hacker@example.com")

	if err := sender.Send(msg, receiver); err != nil {
		panic(err)
	}

Documentation

Overview

package gsender makes smtp easy to use.

Installation

go get github.com/voids/gsender

Get started

sender := new(gsender.Sender)
sender.Address = "voids@example.com"
sender.Name = "voids"
sender.Password = "********"
sender.Host = "smtp.example.com"
sender.Port = 25
// sender.TLS = true

msg := new(gsender.Message)
// msg.Html = true
msg.SetSubject("A test email")
msg.SetBody("this is a test email which sent by golang.")
if err := msg.AddAttachment(`/home/voids/pic.jpg`); err != nil {
	panic(err)
}

receiver := new(gsender.Receiver)
receiver.AddTo("John", "John@example.com")
receiver.AddTo("Lily", "Lily@example.com")
receiver.AddCc("Dog", "dog@example.com")
receiver.AddBcc("hacker", "hacker@example.com")

if err := sender.Send(msg, receiver); err != nil {
	panic(err)
}

Index

Constants

View Source
const BASE64_MAX_LEN = 76

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	// contains filtered or unexported fields
}

type Mail

type Mail mail.Address

func (*Mail) String

func (m *Mail) String() string

type Message

type Message struct {

	// set the type to "html" if Html is true.
	Html bool
	// contains filtered or unexported fields
}

func (*Message) AddAttachment

func (m *Message) AddAttachment(filename string) error

func (*Message) SetBody

func (m *Message) SetBody(body string)

func (*Message) SetSubject

func (m *Message) SetSubject(subject string)

type Receiver

type Receiver struct {
	// contains filtered or unexported fields
}

func (*Receiver) AddBcc

func (r *Receiver) AddBcc(name, email string)

func (*Receiver) AddCc

func (r *Receiver) AddCc(name, email string)

func (*Receiver) AddTo

func (r *Receiver) AddTo(name, email string)

type Sender

type Sender struct {
	Mail
	Password string
	Host     string
	Port     uint
	TLS      bool
}

func (*Sender) Send

func (s *Sender) Send(m *Message, r *Receiver) error

Jump to

Keyboard shortcuts

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