smtpoauth2

package module
v0.0.0-...-a7652b6 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: MIT Imports: 3 Imported by: 0

README

smtpoauth2

Go net/smtp Auth provider for oauth2

Usage

To get started you will need a token.json. The easiest way to generate that is with the googleworkshop/go-samples gmail api quickstart tool. I have included a modified version in this repository that includes the appropriate scope for email sending under cmd/quickstart

After that just import "github.com/jacobalberty/smtpoauth2" and use smtpoauth2.Oauth2(user, tokenType, token) to return an auth object suitable for net/smtp. tokenType will most likely be Bearer and token is the access_token from your previosly generated token.json.

There is sample code in cmd/sendmail that reads token.json and will send an email using this auth provider.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Oauth2

func Oauth2(user, tokenType, token string) smtp.Auth

Returns an AUTH that implements XOAUTH2 authentication user is your email username (normally your email address) tokenType is usually going to be "Bearer" token is your access_token generated by a tool like quickstart

Types

This section is empty.

Directories

Path Synopsis
cmd
quickstart Module

Jump to

Keyboard shortcuts

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