postfix

package module
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

postfix

Sending mail through postfix SMTP server

example

import (
	"github.com/vanng822/postfix"
)
fromAddr := postfix.NewAddress(from, fromEmail)
toAddr := postfix.NewAddress(to, toEmail)
attachment := &postfix.Attachment{
	Filename:    "test.txt",
	ContentType: "text/plain",
	Content:     []byte("test attachment content"),
}

attachment2 := postfix.NewAttachment("test2.txt", "text/plain", []byte("test attachment content 2"))

msg, err := postfix.MultipartMessage(from, to, subject, text, html, attachment, attachment2)
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