gmail

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

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 9 Imported by: 0

README

gmail

library for sending email using gmail credentials.

Usage

package main

import (
    ...
    
    "github.com/t4ke0/gmail"
    ...
)

func main() {

    username := os.Getenv("GMAIL_USERNAME")
    password := os.Getenv("GMAIL_PASSWORD")

    em := gmail.NewEmail(username, password, gmail.EmailConfig{
        From:        username,
        To:          []string{""}, // put your recipients here
        Subject:     "", // subject here
        MessageText: "", // text body message
        Attachements: []string{}, // files attachments here.
    })

    if err := em.Marshal().Send().Error(); err != nil {
        log.Fatal(err)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Email

type Email struct {
	EmailConfig
	// contains filtered or unexported fields
}

Email structure that represents an email. holds email creds and configuration

func NewEmail

func NewEmail(username, password string, cfg EmailConfig) *Email

NewEmail construct a new email returns a pointer to Email structure.

func (*Email) Error

func (e *Email) Error() error

Error check if there is any error that occurs while processing the email or while sending it.

func (*Email) Marshal

func (e *Email) Marshal() *Email

Marshal prepare email form

func (*Email) Send

func (e *Email) Send() *Email

Send sends the email.

type EmailConfig

type EmailConfig struct {
	From         string
	To           []string
	Subject      string
	MessageText  string
	Boundary     string
	BoundaryRepr string

	Attachements []string
}

EmailConfig

type TemplateItems

type TemplateItems struct {
	EmailConfig
	Recipient string
}

TemplateItems template fields to replace

Jump to

Keyboard shortcuts

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