loginauth

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

README

LoginAuth

Login Authorization option for sending email over SMTP with Go. Particularly useful for Office365 accounts such as Outlook.com or Exchange Online.

If you've been trying to send email over SMTP and keep getting an error like "Error tls: first record does not look like a TLS handshake" this package might help.

EXAMPLE

server   := "smtp.office365.com:587"
sender   := "example1@example.com"
password := "hunter2"
subject  := "Test"
message  := "Hello world."
receiver := []string{"example2@example.com"}

auth := loginauth.Auth(sender, password)

body := []byte("Subject:"+subject+"\r\n\r\n"+message)
err := smtp.SendMail(server, auth, sender, receiver, body)
if err != nil {
    log.Fatal(err)
}
log.Println("Email sent successfully.")

Documentation

Overview

Package loginauth provides an smtp.Auth for LOGIN authentication.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknown = errors.New("unknown from server")

Functions

func Auth

func Auth(username, password string) smtp.Auth

Auth returns an smtp.Auth that provides LOGIN authentication.

Types

This section is empty.

Jump to

Keyboard shortcuts

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