Giter Club home page Giter Club logo

mail's Introduction

This repository contains mail packages for Go:

  • gomail is the main package of this repository, it provides a simple interface to easily write and send emails.
  • mailer provides functions to easily send emails. It should be used with or inside a package that helps writing emails like it is done in gomail.
  • quotedprintable is a package that implements quoted-printable and message header encoding. Someday, it might enter the Go standard library.

You are more than welcome to ask questions on the Go mailing-list and open issues here if you find bugs.

gomail

Documentation

Package gomail provides a simple interface to easily write and send emails.

Example:

package main

import (
    "log"

    "github.com/alexcesaro/mail/gomail"
)

func main() {
    msg := gomail.NewMessage()
    msg.SetAddressHeader("From", "[email protected]", "Alex")
    msg.SetHeader("To", "[email protected]")
    msg.AddHeader("To", "[email protected]")
    msg.SetHeader("Subject", "Hello!")
    msg.SetBody("text/plain", "Hello Bob and Cora!")
    msg.AddAlternative("text/html", "Hello <b>Bob</b> and <i>Cora</i>!")
    if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
        log.Println(err)
        return
    }

    m := gomail.NewMailer("smtp.example.com", "user", "123456", 25)
    if err := m.Send(msg); err != nil { // This will send the email to Bob and Cora
        log.Println(err)
    }
}

mailer

Documentation

Package mailer provides functions to easily send emails.

This package can be used as a standalone but if you want to send emails with non-ASCII characters or with attachment you should use it with or inside a package that helps writing emails like it is done in gomail.

package main

import (
    "log"
    "net/mail"
    "strings"

    "github.com/alexcesaro/mail/mailer"
)

func main() {
    msg := &mail.Message{
        mail.Header{
            "From":         {"[email protected]"},
            "To":           {"[email protected]", "[email protected]"},
            "Subject":      {"Hello!"},
            "Content-Type": {"text/plain"},
        },
        strings.NewReader("Hello, how are you ?"),
    }

    m := mailer.NewMailer("smtp.example.com", "user", "123456", 25)
    if err := m.Send(msg); err != nil { // This will send the email to Bob and Cora
        log.Println(err)
    }
}

quotedprintable

Documentation

Package quotedprintable implements quoted-printable and message header encoding as specified by RFC 2045 and RFC 2047.

Someday, it might enter the Go standard library. See this post on the golang-dev mailing-list or this code review or issue 4943 of the Go bug tracker.

mail's People

Contributors

alexcesaro avatar chy168 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.