rmailer

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

README

rmailer

library in go to send mails with attachments via smtp protocol

package main

import (
  rmailer "github.com/RaoH37/rmailer"
)

func main() {
  sender := rmailer.NewSender("toto@toto.fr", "secret", "mta.toto.fr:465")

  m := rmailer.NewMessage("Hello", "It's a good day to do nothing !")

  m.From = mail.Address{Address: "toto@toto.fr"}
  m.To = []mail.Address{
		{Address: "tata@tata.fr"},
	}

  m.AttachFile("/tmp/file_1.txt")
  m.AttachFile("/tmp/file_2.txt")

  sender.Send(m)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	From        mail.Address
	To          []mail.Address
	CC          []mail.Address
	BCC         []mail.Address
	Subject     string
	Body        string
	Attachments map[string][]byte
}

func NewMessage

func NewMessage(subject, content string) *Message

func (*Message) AttachFile

func (m *Message) AttachFile(path string) error

func (*Message) SetBccFromStrings added in v1.1.1

func (m *Message) SetBccFromStrings(ss []string)

func (*Message) SetCcFromStrings added in v1.1.1

func (m *Message) SetCcFromStrings(ss []string)

func (*Message) SetFromFromString added in v1.1.1

func (m *Message) SetFromFromString(s string)

func (*Message) SetToFromStrings added in v1.1.1

func (m *Message) SetToFromStrings(ss []string)

func (*Message) ToBytes

func (m *Message) ToBytes() []byte

type Sender

type Sender struct {
	UserName string
	Password string
	Host     string
}

func NewSender

func NewSender(u string, p string, s string) *Sender

func (*Sender) AnonymousSend

func (s *Sender) AnonymousSend(m *Message) error

func (*Sender) AuthenticatedSend

func (s *Sender) AuthenticatedSend(m *Message) error

func (*Sender) IsAuthenticated

func (s *Sender) IsAuthenticated() bool

func (*Sender) Send

func (s *Sender) Send(m *Message) error

Jump to

Keyboard shortcuts

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