postfix

package module
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 5 Imported by: 0

README

postfix

Sending mail through postfix SMTP server

example

import (
	"github.com/vanng822/postfix"
)
fromAddr := postfix.NewAddress(from, fromEmail)
toAddr := postfix.NewAddress(to, toEmail)
msg, err := postfix.MultipartMessage(fromAddr, toAddr, subject, text, html)
if err != nil {
	log.Fatal("Postfix mailing with error", err)
}
err := postfix.Send(msg)
if err != nil {
	log.Fatal("Postfix mailing with error", err)
}

Documentation

Overview

Package postfix is for sending mail

import (

"github.com/vanng822/postfix"

)

fromAddr := postfix.NewAddress(from, fromEmail) toAddr := postfix.NewAddress(to, toEmail) msg, err := postfix.MultipartMessage(fromAddr, toAddr, subject, text, html)

if err != nil {
	log.Fatal("Postfix mailing with error", err)
}

err := postfix.Send(msg)

if err != nil {
	log.Fatal("Postfix mailing with error", err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hello added in v0.12.0

func Hello() error

func MultipartMessage

func MultipartMessage(from *mail.Address, to *mail.Address, subject, text, html string, attachments ...*Attachment) (*mail.Message, error)

MultipartMessage create a message with multipart text and html html part is parsed and applied css inline styling

func NewAddress

func NewAddress(name, address string) *mail.Address

NewAddress return new mail.Address

func Noop added in v0.12.0

func Noop() error

func Send

func Send(msg *mail.Message) error

Send connects to a smtp server and send the message to all recipients

func SetClientFactory

func SetClientFactory(f func() (c *smtp.Client, err error))

SetClientFactory for setting a smtp client if needed

func SetHost

func SetHost(h string)

func SetPort

func SetPort(p int)

Types

type Attachment added in v0.8.0

type Attachment struct {
	Filename    string
	ContentType string
	Content     []byte
}

func NewAttachment added in v0.11.0

func NewAttachment(filename, contentType string, content []byte) *Attachment

Jump to

Keyboard shortcuts

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