gmailer

package module
v0.0.0-...-0cb9f01 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 5 Imported by: 0

README

GMAILER

A tiny library for sending gmails. I use it in my programs to send me email alerts when things happen that I need to know about. Simply form a gmailer.Message and then call its method Send()

NOTE:

On the first run of this app it will look for a client_secret.json file in the root directory of your project. It will then prompt you to visit a page to copy/paste an access token from the resulting web address back into the terminal. It will then store a file in ~/.credentials that will be used every time to conect to the gmail api from then on.

client_secret.json can be generated from within an app on google cloud platform.

If other programs attempt to interact with the gmail api, one of these files could cause an error.

Example:

package main

import (
        "fmt"
        "github.com/hartsfield/gmailer"
)

func main() {
        msg := gmailer.Message{
                Recipient: "YOUR___GMAIL___HERE@gmail.com",
                Subject:   "ALERT! Server has exceeded the maximum number of open file descriptors",
                Body:      "...",
        }
        msg.Send(onMessageSent)
}

func onMessageSent() {
        fmt.Println("Message sent successfully")
}

Documentation

Overview

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Recipient string
	Subject   string
	Body      string
}

Message allows us to send messages

func (*Message) Send

func (m *Message) Send(cb func())

Send allows us to send the email

Jump to

Keyboard shortcuts

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