xmail

package
v0.25.15 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

GoKit - xmail

Mail kits for Golang development.

Features

  • Light weight and Easy to use
  • Attachment sending support
  • Plain text sending support
  • TLS sending support

Installation

go get -u github.com/likexian/gokit

Importing

import (
    "github.com/likexian/gokit/xmail"
)

Documentation

Visit the docs on GoDoc

Example

Send mail
// Set the smtp info
// New("smtp server:port", "smtp username", "smtp password", isTLS)
m := New("smtp.likexian.com:465", "i@likexian.com", "8Bd0a7681333214", true)

// Set email from
m.From("i@likexian.com")

// Set send to
m.To("to@likexian.com")

// Set send cc
m.Cc("cc@likexian.com")

// Set send bcc
m.BCc("bcc@likexian.com")

// set mail content type
m.ContentType("text/html")

// Set mail subject
m.Content("Mailer Test", "xmail via github.com/likexian/gokit/xmail.<br /><img src=\"cid:xmail_test.jpg\" />")

// Add attachment
err := m.Attach("xmail_test.jpg")
if err != nil {
    panic(err)
}

err = m.Send()
if err != nil {
    panic(err)
}

License

Copyright 2012-2024 Li Kexian

Licensed under the Apache License 2.0

Donation

If this project is helpful, please share it with friends.

If you want to thank me, you can give me a cup of coffee.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Author

func Author() string

Author returns package author

func License

func License() string

License returns package license

func Version

func Version() string

Version returns package version

Types

type Message added in v0.25.4

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

Message storing mail message

func New

func New(server, username, password string, tls bool) (m *Message)

New returns a new xmail

func (*Message) Attach added in v0.25.4

func (m *Message) Attach(fname string) (err error)

Attach add a attachment

func (*Message) BCc added in v0.25.4

func (m *Message) BCc(s ...string) error

BCc set mail bcc

func (*Message) Cc added in v0.25.4

func (m *Message) Cc(s ...string) error

Cc set mail cc

func (*Message) Content added in v0.25.4

func (m *Message) Content(subject, body string) error

Content set mail content

func (*Message) ContentType added in v0.25.4

func (m *Message) ContentType(t string) error

ContentType set mail content type

func (*Message) From added in v0.25.4

func (m *Message) From(s string) error

From set mail from

func (*Message) Send added in v0.25.4

func (m *Message) Send() (err error)

Send do the sending

func (*Message) To added in v0.25.4

func (m *Message) To(s ...string) error

To set mail to

Jump to

Keyboard shortcuts

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