mailiosmtphelpers

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: Apache-2.0 Imports: 16 Imported by: 4

README

Mailio Smtp helper functions.

Helper functions

// converting html/text into plain/text
htmlToText(myHtml)
// generates RFC2822 compliant Message-ID
generateRFC2822MessageID()
// ToMime converts a Mailio specific struct to email Mime message
ToMime(msg *types.Mail) ([]byte, error)

// ToBounce converts a Mailio specific struct to a RFC compliant bounce message
ToBounce(recipient mail.Address, msg types.Mail, bounceCode string, bounceReason string) ([]byte, error)

// ToComplaint converts a Mailio specific struct to a RFC compliant complaint message
ToComplaint(recipient mail.Address, reporter mail.Address, msg types.Mail, complaintReason string) ([]byte, error)

// ParseMime parses an email message and returns a Mailio specific struct
ParseMime(mime []byte) (*types.Mail, error)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRFC2822MessageID

func GenerateRFC2822MessageID(hostname string) (string, error)

GenerateMessageID generates and returns a string suitable for an RFC 2822 compliant Message-ID, e.g.: <1444789264909237300.3464.1819418242800517193@DESKTOP01>

The following parameters are used to generate a Message-ID: - The nanoseconds since Epoch - The calling PID - A cryptographically random int64 - The sending hostname

func HtmlToText

func HtmlToText(html string) string

func ParseMime

func ParseMime(mime []byte) (*abi.Mail, error)

Parsing raw mime message into a Mailio structure

func ToBounce

func ToBounce(recipient mail.Address, msg abi.Mail, bounceCode string, bounceReason string, mailhost string) ([]byte, error)

Recommeneded to handle the following bounce reasons: Mailbox Does Not Exist — SMTP Reply Code = 550, SMTP Status Code = 5.1.1 Message Too Large — SMTP Reply Code = 552, SMTP Status Code = 5.3.4 Mailbox Full — SMTP Reply Code = 552, SMTP Status Code = 5.2.2 Message Content Rejected — SMTP Reply Code = 500, SMTP Status Code = 5.6.1 Unknown Failure — SMTP Reply Code = 554, SMTP Status Code = 5.0.0 Temporary Failure — SMTP Reply Code = 450, SMTP Status Code = 4.0.0

where 4.x.x codes are soft bounces, and 5.x..x codes are hard bounces

func ToComplaint

func ToComplaint(recipient mail.Address, reporter mail.Address, msg abi.Mail, complaintReason string, mailhost string) ([]byte, error)

ToComplaint creates a complaint message

Complaints are generated when a recipient reports an email as spam or junk. The recipient's email provider sends a complaint to the custom ESP. The complaint includes the original email that was reported as spam or junk. The complaint also includes information about the recipient who reported the email as spam or junk.

https://en.wikipedia.org/wiki/Abuse_Reporting_Format https://datatracker.ietf.org/doc/html/rfc5965

func ToMime

func ToMime(msg *abi.Mail, rfc2822MessageID string) ([]byte, error)

converts a message to a mime message. Required rfc2822 compliant message id

Types

This section is empty.

Jump to

Keyboard shortcuts

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