emersion / Go Smtp
Licence: mit
📤 An SMTP client & server library written in Go
Stars: ✭ 655
Programming Languages
go
31211 projects - #10 most used programming language
Projects that are alternatives of or similar to Go Smtp
James Project
Emails at the heart of your business logic!
Stars: ✭ 485 (-25.95%)
Mutual labels: mail, smtp, server
Chasquid
SMTP (email) server with a focus on simplicity, security, and ease of operation [mirror]
Stars: ✭ 427 (-34.81%)
Mutual labels: mail, smtp, server
Hedwig
Send email to any SMTP server like a boss, in Swift and cross-platform
Stars: ✭ 1,096 (+67.33%)
Mutual labels: mail, smtp, server
Go Imap
📥 An IMAP library for clients and servers
Stars: ✭ 1,217 (+85.8%)
Mutual labels: mail, server, client
Mailinabox
Mail-in-a-Box helps individuals take back control of their email by defining a one-click, easy-to-deploy SMTP+everything else server: a mail server in a box.
Stars: ✭ 10,649 (+1525.8%)
Mutual labels: mail, smtp, server
Mailcatcher
Catches mail and serves it through a dream.
Stars: ✭ 5,512 (+741.53%)
Mutual labels: mail, smtp, server
Graphql Ws
Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client.
Stars: ✭ 398 (-39.24%)
Mutual labels: server, client
Mailcow Dockerized
mailcow: dockerized - 🐮 + 🐋 = 💕
Stars: ✭ 4,573 (+598.17%)
Mutual labels: mail, smtp
Mail
Library to send e-mails over different transports and protocols (like SMTP and IMAP) using immutable messages and streams. Also includes SMTP server.
Stars: ✭ 399 (-39.08%)
Mutual labels: mail, smtp
Node Bluetooth Serial Port
Serial I/O over bluetooth for NodeJS
Stars: ✭ 444 (-32.21%)
Mutual labels: server, client
Mumble
Mumble is an open-source, low-latency, high quality voice chat software.
Stars: ✭ 4,418 (+574.5%)
Mutual labels: server, client
Mirakurun
A Modern DTV Tuner Server Service for ISDB.
Stars: ✭ 352 (-46.26%)
Mutual labels: server, client
Rainloop Webmail
Simple, modern & fast web-based email client
Stars: ✭ 3,618 (+452.37%)
Mutual labels: mail, smtp
Nodepolus
NodePolus is a JavaScript library containing multiple implementations of the Among Us network protocol.
Stars: ✭ 331 (-49.47%)
Mutual labels: server, client
Happypandax
A cross-platform server and client application for managing and reading manga and doujinshi
Stars: ✭ 432 (-34.05%)
Mutual labels: server, client
Blacksheep
Fast ASGI web framework and HTTP client for Python asyncio
Stars: ✭ 450 (-31.3%)
Mutual labels: server, client
Networksocket
NetworkSocket是一个以中间件(middleware)扩展通讯协议,以插件(plug)扩展服务器功能的支持SSL安全传输的通讯框架;目前支持http、websocket、fast、flex策略与silverlight策略协议。
Stars: ✭ 435 (-33.59%)
Mutual labels: server, client
Awesome Openapi3
😎 A list of awesome projects related to OpenAPI 3.0.x, curated by the community
Stars: ✭ 469 (-28.4%)
Mutual labels: server, client
go-smtp
An ESMTP client and server library written in Go.
Features
- ESMTP client & server implementing RFC 5321
- Support for SMTP AUTH and PIPELINING
- UTF-8 support for subject and message
- LMTP support
Usage
Client
package main
import (
"log"
"strings"
"github.com/emersion/go-sasl"
"github.com/emersion/go-smtp"
)
func main() {
// Set up authentication information.
auth := sasl.NewPlainClient("", "[email protected]", "password")
// Connect to the server, authenticate, set the sender and recipient,
// and send the email all in one step.
to := []string{"[email protected]"}
msg := strings.NewReader("To: [email protected]\r\n" +
"Subject: discount Gophers!\r\n" +
"\r\n" +
"This is the email body.\r\n")
err := smtp.SendMail("mail.example.com:25", auth, "[email protected]", to, msg)
if err != nil {
log.Fatal(err)
}
}
If you need more control, you can use Client
instead.
Server
package main
import (
"errors"
"io"
"io/ioutil"
"log"
"time"
"github.com/emersion/go-smtp"
)
// The Backend implements SMTP server methods.
type Backend struct{}
// Login handles a login command with username and password.
func (bkd *Backend) Login(state *smtp.ConnectionState, username, password string) (smtp.Session, error) {
if username != "username" || password != "password" {
return nil, errors.New("Invalid username or password")
}
return &Session{}, nil
}
// AnonymousLogin requires clients to authenticate using SMTP AUTH before sending emails
func (bkd *Backend) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, error) {
return nil, smtp.ErrAuthRequired
}
// A Session is returned after successful login.
type Session struct{}
func (s *Session) Mail(from string, opts smtp.MailOptions) error {
log.Println("Mail from:", from)
return nil
}
func (s *Session) Rcpt(to string) error {
log.Println("Rcpt to:", to)
return nil
}
func (s *Session) Data(r io.Reader) error {
if b, err := ioutil.ReadAll(r); err != nil {
return err
} else {
log.Println("Data:", string(b))
}
return nil
}
func (s *Session) Reset() {}
func (s *Session) Logout() error {
return nil
}
func main() {
be := &Backend{}
s := smtp.NewServer(be)
s.Addr = ":1025"
s.Domain = "localhost"
s.ReadTimeout = 10 * time.Second
s.WriteTimeout = 10 * time.Second
s.MaxMessageBytes = 1024 * 1024
s.MaxRecipients = 50
s.AllowInsecureAuth = true
log.Println("Starting server at", s.Addr)
if err := s.ListenAndServe(); err != nil {
log.Fatal(err)
}
}
You can use the server manually with telnet
:
$ telnet localhost 1025
EHLO localhost
AUTH PLAIN
AHVzZXJuYW1lAHBhc3N3b3Jk
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
DATA
Hey <3
.
Relationship with net/smtp
The Go standard library provides a SMTP client implementation in net/smtp
.
However net/smtp
is frozen: it's not getting any new features. go-smtp
provides a server implementation and a number of client improvements.
Licence
MIT
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].