emailer

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: MIT Imports: 8 Imported by: 0

README

emailer

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

import

import "github.com/ElrondfromRussia/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 Margaret

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 // attached file name
	FileData []byte // attached file bytes
}

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 object.

func (*Sender) NewMessage

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

Creating new email message with attachments.

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