All Projects → kataras → go-mailer

kataras / go-mailer

Licence: MIT license
📫 Simple e-mail sender for Go Programming Language

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-mailer

ESP-Mail-Client
⚡️Arduino Mail Client Library to send, read and get incoming mail notification for ESP32, ESP8266 and SAMD21 devices. The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.
Stars: ✭ 78 (+151.61%)
Mutual labels:  mail, sendmail
Free Email Forwarding
The best free email forwarding for custom domains. Visit our website to get started (SMTP server)
Stars: ✭ 2,024 (+6429.03%)
Mutual labels:  mail, sendmail
Mail
The Hoa\Mail library.
Stars: ✭ 24 (-22.58%)
Mutual labels:  mail, sendmail
vim-gnote
make your mailbox as a note place
Stars: ✭ 16 (-48.39%)
Mutual labels:  mail
laravel-mail-aliyun
📧 Aliyun DrirectMail Transport for Laravel Application.
Stars: ✭ 69 (+122.58%)
Mutual labels:  mail
vertx-mail-client
No description or website provided.
Stars: ✭ 30 (-3.23%)
Mutual labels:  mail
go-mail
📨 Simple email interface across multiple service providers (ses, postmark, mandrill, smtp)
Stars: ✭ 39 (+25.81%)
Mutual labels:  mail
mailer
Generic mailer
Stars: ✭ 16 (-48.39%)
Mutual labels:  mail
crowd-admin
crowd-admin是一个基于Spring,Shiro,Redis/ehcache,Mybatis的通用后台权限管理系统,这里推荐本人另一个基于sprinboot的单点登录系统
Stars: ✭ 51 (+64.52%)
Mutual labels:  mail
mu4e-thread-folding
Functions for folding threads in mu4e headers view
Stars: ✭ 124 (+300%)
Mutual labels:  mail
COSCUP2013Secretary-Toolkit
✉️ COSCUP2013 行政組專用的小工具 AWS SES, SQS, SNS, twilio
Stars: ✭ 13 (-58.06%)
Mutual labels:  mail
email-validator.dart
A simple Dart class for validating email addresses without using RegEx 📧
Stars: ✭ 156 (+403.23%)
Mutual labels:  mail
inox
Email with notmuch rust
Stars: ✭ 22 (-29.03%)
Mutual labels:  mail
go-imap-idle
IDLE extension for go-imap
Stars: ✭ 30 (-3.23%)
Mutual labels:  mail
nettemp
Interface for controlling the temperature sensors DS18B20, supports; serial DS9097, usb DS9097U, usb DS2490, Raspberry Pi GPIO
Stars: ✭ 53 (+70.97%)
Mutual labels:  mail
mlmmjadmin
A simple RESTful API server used to manage mlmmj (http://mlmmj.org) mailing list manager.
Stars: ✭ 39 (+25.81%)
Mutual labels:  mail
james-jdkim
Mirror of Apache James jdkim
Stars: ✭ 19 (-38.71%)
Mutual labels:  mail
skirnir
Skirnir Email Server
Stars: ✭ 31 (+0%)
Mutual labels:  mail
convey
CSV processing and web related data types mutual conversion
Stars: ✭ 16 (-48.39%)
Mutual labels:  e-mail
fs2-mail
asynchronous library for sending and receiving mail via fs2._
Stars: ✭ 39 (+25.81%)
Mutual labels:  mail

Mailer

Simple E-mail sender written in Go. Mailer supports rich e-mails and, optionally, *nix built'n sendmail command.

Build Status License Releases Godocs Build Status Built with GoLang Platforms

Installation

The only requirement is the Go Programming Language.

$ go get -u github.com/kataras/go-mailer

Getting Started

  • New returns a new, e-mail sender service.
  • Mailer#Send send an e-mail, supports text/html and sendmail unix command
// New returns a new *Mailer, which contains the Send methods.
New(cfg Config) *Mailer
// SendWithBytes same as `Send` but it accepts the body as raw []byte,
// it's the fastest method to send e-mails.
SendWithBytes(subject string, body []byte, to ...string) error 

// Send sends an email to the recipient(s)
// the body can be in HTML format as well.
Send(subject string, body string, to ...string) error

// SendWithReader same as `Send` but it accepts
// an io.Reader that body can be retrieved and call the `SendWithBytes`.
SendWithReader(subject string, bodyReader io.Reader, to ...string) error

// SendWithReadCloser same as `SendWithReader` but it closes the reader at the end.
SendWithReadCloser(subject string, bodyReader io.ReadCloser, to ...string) error

Configuration

// Config contains those necessary fields that Mailer needs to send e-mails.
type Config struct {
    // Host is the server mail host, IP or address.
    Host string
    // Port is the listening port.
    Port int
    // Username is the auth [email protected] for the sender.
    Username string
    // Password is the auth password for the sender.
    Password string
    // FromAddr is the 'from' part of the mail header, it overrides the username.
    FromAddr string
    // FromAlias is the from part, if empty this is the first part before @ from the Username field.
    FromAlias string
    // UseCommand enable it if you want to send e-mail with the mail command  instead of smtp.
    //
    // Host,Port & Password will be ignored.
    // ONLY FOR UNIX.
    UseCommand bool
}

Example

$ cat example.go
package main

import "github.com/kataras/go-mailer"

func main() {
    // sender configuration.
    config := mailer.Config{
        Host:     "smtp.mailgun.org",
        Username: "postmaster",
        Password: "38304272b8ee5c176d5961dc155b2417",
        FromAddr: "[email protected]",
        Port:     587,
        // Enable UseCommand to support sendmail unix command,
        // if this field is true then Host, Username, Password and Port are not required,
        // because these info already exists in your local sendmail configuration.
        //
        // Defaults to false.
        UseCommand: false,
    }

    // initalize a new mail sender service.
    sender := mailer.New(config)

    // the subject/title of the e-mail.
    subject := "Hello subject"

    // the rich message body.
    content := `<h1>Hello</h1> <br/><br/> <span style="color:red"> This is the rich message body </span>`

    // the recipient(s).
    to := []string{"[email protected]", "[email protected]"}

    // send the e-mail.
    err := sender.Send(subject, content, to...)

    if err != nil {
        println("error while sending the e-mail: " + err.Error())
    }
}
$ go run example.go

FAQ

Explore these questions or navigate to the community chat.

Versioning

Current: v0.1.0

Read more about Semantic Versioning 2.0.0

Upgrading from version 0.0.3 to 0.1.0

One breaking change:

The Send commands accept a to ...string instead of to []string now, this is an API Change, if you got multiple to emails then just append three dots at the end ... and you'll be fine, i.e

sender := mailer.New(mailer.Config{...})
to := []string{"[email protected]", "[email protected]"}
sender.Send("subject", "<p>body</p>", to...)

People

The author of go-mailer is @kataras.

Contributing

If you are interested in contributing to the go-mailer project, please make a PR.

TODO

  • Add a simple CLI tool for sending emails

License

This project is licensed under the MIT License. License file can be found here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].