emailer

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: MIT Imports: 9 Imported by: 0

README

emailer

Tiny lib for email (with attachments) sending (smtp)

import

import "github.com/NGRsoftlab/ngr-emailer"

example

s := NewSender(
		"user@mail.com",
		"password",
		"user@mail.com",
		fmt.Sprintf("%v:%v", "test.com", "587"),
	)

	err := s.NewMessage("topic", []string{"user@mail.com"}, "test", []AttachData{{
		fileName: "test.txt",
		fileData: []byte("test"),
	}})
	if err != nil {
		log.Fatal(err)
	}
	err = s.Send()
	if err != nil {
		log.Fatal(err)
	}

Documentation

Overview

Copyright 2020 NGR Softlab

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoginAuth

func LoginAuth(username, password string) smtp.Auth

Auth with login and password.

Types

type AttachData

type AttachData struct {
	FileName string
	FileData []byte
}

Struct for attachments.

type Sender

type Sender struct {
	Login      string // user login
	Email      string // user email address
	Password   string // user password
	ServerSMTP string // smtp server string
	// contains filtered or unexported fields
}

Struct - sender for sending smtp packs.

func NewSender

func NewSender(login, password, email, server string) *Sender

Creating new *Sender obj.

func (*Sender) NewMessage

func (s *Sender) NewMessage(subject string, to []string, body string, files []AttachData) error

Creating new email message.

func (*Sender) Send

func (s *Sender) Send() error

Send smtp pack (mail).

Jump to

Keyboard shortcuts

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