siba

package
v5.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: BSD-2-Clause Imports: 12 Imported by: 1

Documentation

Overview

Package "siba" provides types for data structure of sisimai SIBA stands for Sisimai Internal Bounce Abstraction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BeforeFact

type BeforeFact struct {
	Headers map[string][]string // Email headers of the bounce mail
	RFC822  map[string][]string // Email headers of the original message
	Digest  []DeliveryMatter    // Decoded results returned from lhost/via-*.go
	Errors  []NotDecoded        // All the errors and warnings
	Catch   any                 // Any data structure returned by the callback function [0]
	Sender  string              // Unix FROM line ("From ")
	Payload string              // Entire message body of the bounce mail
}

message.Rise() returns BeforeFact{}.

func (*BeforeFact) HasDone

func (be *BeforeFact) HasDone() bool

*BeforeFact.HasDone returns false when Digest or RFC822 is empty.

func (*BeforeFact) IsEmpty

func (be *BeforeFact) IsEmpty() bool

*BeforeFact.IsEmpty returns true when Headers or body is empty.

type CallbackArg0

type CallbackArg0 struct {
	Headers map[string][]string // Email headers of the bounce mail
	Payload *string             // Entire message body of the bounce mail
}

CallbackArg0 is an argument of the first callback function that are called at message.sift(). It is aliased to sisimai.CallbackArg0 at the libsisimai.go.

type CallbackArg1

type CallbackArg1 struct {
	Fact *[]Fact // Decoded results
	Path string  // Path to the original email file or "<STDIN>" or "<MEMORY>"
	Kind string  // Kind of the original email file or "stdin" or "memory"
	Mail *string // Entire message body of the bounce mail including all the headers
}

CallbackArg1 is an argument of the callback functions that are called at sisimai.Rise(). It is aliased to sisimai.CallbackArg1 at the libsisimai.go.

type CfParameter0

type CfParameter0 func(arg *CallbackArg0) (map[string]any, error)

CfParameter* is an argument of the callback function specified at sisimai.Rise().

type CfParameter1

type CfParameter1 func(arg *CallbackArg1) (bool, error)

type DecodingArgs

type DecodingArgs struct {
	Callback0 CfParameter0 // [0] The 1st callback function
	Callback1 CfParameter1 // [1] The 2nd callback function
	Delivered bool         // Include siba.Fact{}.Action = "delivered" records in the decoded data
	Vacation  bool         // Include siba.Fact{}.Reason = "Vacation" records in the decoded data
}

DecodingArgs is an argument of the sisimai.Rise() function.

type DeliveryMatter

type DeliveryMatter struct {
	Action       string // The value of Action header
	Agent        string // MTA name
	Alias        string // The value of alias entry(RHS)
	Command      string // SMTP command in the message body
	Date         string // The value of Last-Attempt-Date header
	Diagnosis    string // The value of Diagnostic-Code header
	FeedbackType string // Feedback type
	Lhost        string // The value of Received-From-MTA header
	Reason       string // Temporary reason of bounce
	Recipient    string // The value of Final-Recipient header
	ReplyCode    string // SMTP Reply Code
	Rhost        string // The value of Remote-MTA header
	Spec         string // Protocol specification
	Status       string // The value of Status header
}

func NextDeliveryMatter

func NextDeliveryMatter(de *[]DeliveryMatter) *DeliveryMatter

NextDeliveryMatter appends a new element and returns the last element pointer.

Arguments:
  - de (*[]DeliveryMatter): The pointer to []DeliveryMatter.
Returns:
  - (*DeliveryMatter): The last element pointer of DeliveryMatter struct.

func TailDeliveryMatter

func TailDeliveryMatter(de []DeliveryMatter) *DeliveryMatter

TailDeliveryMatter returns the last element pointer of DeliveryMatter struct.

Arguments:
  - de ([]DeliveryMatter): []DeliveryMatter
Returns:
  - (*DeliveryMatter): The last element pointer of DeliveryMatter struct.

func (*DeliveryMatter) AsRFC1894

func (de *DeliveryMatter) AsRFC1894(field string) string

*DeliveryMatter.AsRFC1894 returns a lower-cased member name converted from a field name defined in RFC1894.

Arguments:
  - field (string): Field name defined in RFC1894.
Returns:
  - (string): Member name of siba.DeliveryMatter struct.

func (*DeliveryMatter) Select

func (de *DeliveryMatter) Select(field string) string

*DeliveryMatter.Select returns the current value of the siba.DeliveryMatter instance.

Arguments:
  - field (string): Lower-cased member name of siba.DeliveryMatter.
Returns:
  - (string): The value of the member name specified at "field".

func (*DeliveryMatter) Update

func (de *DeliveryMatter) Update(field string, value string) bool

*DeliveryMatter.Update set the argument into the member of siba.DeliveryMatter instance.

Arguments:
  - field (string): Lower-cased member name of siba.DeliveryMatter.
  - value (string): New value to be updated.
Returns:
  - (bool): true if it has updated successfully.

type EmailAddress

type EmailAddress struct {
	Address string // Email address
	User    string // Local part of the email address
	Host    string // Domain part of the email address
	Verp    string // Expanded VERP address
	Alias   string // Expanded Alias of the email address
	Name    string // Display name
	Comment string // (Comment)
}

type Fact

type Fact struct {
	Action         string       `json:"action"`         // Value of "Action:" field
	Addresser      EmailAddress `json:"addresser"`      // Sender address of the original message
	Alias          string       `json:"alias"`          // Alias of the recipient address
	Bogus          int          `json:"bogus"`          // (EXPERIMENTAL) Unreliability score of a bounce message
	Catch          any          `json:"catch"`          // Results generated by the user-defined callback function[1]
	Command        string       `json:"command"`        // Last SMTP command
	DecodedBy      string       `json:"decodedby"`      // MTA module name
	DeliveryStatus string       `json:"deliverystatus"` // "Status:" field value or delivery status such as "5.2.2"
	Destination    string       `json:"destination"`    // Domain part of the "Recipient"
	DiagnosticCode string       `json:"diagnosticcode"` // "Diagnostic-Code:" field value or error messages in the message body
	DiagnosticType string       `json:"diagnostictype"` // Subtype of "Diagnostic-Code:" field such as "SMTP", "X-UNIX"
	FeedbackID     string       `json:"feedbackid"`     // Value of Feedback-ID: header of the original message
	FeedbackType   string       `json:"feedbacktype"`   // Feedback Type, always empty except when the Reason is Feedback
	HardBounce     bool         `json:"hardbounce"`     // Hard bounce or not: true, false
	Lhost          string       `json:"lhost"`          // Local mail server hostname (server attempting to send the email).
	ListID         string       `json:"listid"`         // Value of "List-Id" field of the original message
	MessageID      string       `json:"messageid"`      // Value of "Message-Id:" header of the original message
	Origin         string       `json:"origin"`         // Path of the bounce mail as a data source
	Reason         string       `json:"reason"`         // Bounce reason name, which sisimai detected
	Rhost          string       `json:"rhost"`          // remote mail server hostname (server intended to receive the email).
	Recipient      EmailAddress `json:"recipient"`      // Recipient address of the original message
	ReplyCode      string       `json:"replycode"`      // SMTP Reply Code such as "421", which is picked from the error message
	SenderDomain   string       `json:"senderdomain"`   // Domain part of the "Addresser"
	Subject        string       `json:"subject"`        // Value of Subject: header of the original message
	Timestamp      time.Time    `json:"timestamp"`      // Unix machine time(int64) when the email bounced
	TimezoneOffset string       `json:"timezoneoffset"` // Time zone offset of "Timestamp", such as "+0900"
	Token          string       `json:"token"`          // Message token(SHA1 Hex digest value)
	Toxic          int          `json:"toxic"`          // (EXPERIMENTAL) Score-based evaluation of recipient address toxicity
}

func (Fact) Dump

func (fa Fact) Dump() (string, error)

Fact.Dump() returns a serialized siba.Fact{} structure as a JSON string.

Returns:
  - (string): JSON string.
  - (error):  Occurred error.

func (Fact) MarshalJSON

func (fa Fact) MarshalJSON() ([]byte, error)

Fact.MarshalJSON returns a lower-cased member name converted from a field name defined in RFC1894.

Returns:
  - ([]byte): JSON string.
  - (error):  Occurred error.

type NotDecoded

type NotDecoded struct {
	Timestamp time.Time // When the error occurred
	EmailFile string    // An email file name sisimai tried to decoded
	BecauseOf string    // An error message of the failure
	WhoCalled string    // Who called the constructor?
	DecodedBy string    // Copy of siba.Fact.DecodedBy
	CalledOff bool      // Unrecoverable error, the decoding process have called off
}

func MakeNotDecoded

func MakeNotDecoded(mesg string, flag bool) *NotDecoded

MakeNotDecoded is a constructor of siba.NotDecoded struct.

Arguments:
  - mesg (string): Error message.
  - flag (bool):   Unrecoverable error or not.
Returns:
  - (*NotDecoded):  Initialized error struct.

func (*NotDecoded) Email

func (no *NotDecoded) Email(path string) string

*NotDecoded.Email receives a path to email and set it into EmailFile.

Arguments:
  - path (string): Path to an email being set into the EmailFile.
Returns:
  - (string): Current value of the EmailFile.

func (*NotDecoded) Error

func (no *NotDecoded) Error() string

*NotDecoded.Error returns the error message as a string.

Returns:
  - (string): Formatted error message with a timestamp.

func (*NotDecoded) Label

func (no *NotDecoded) Label() string

*NotDecoded.Label returns a label string for printing error message.

Returns:
  - (string): Label string

type RisingUnderway

type RisingUnderway struct {
	Digest []DeliveryMatter // List of DeliveryMatter structs
	Errors []NotDecoded     // Errors occurred in lhost/*
	RFC822 string           // The original message
}

Each MTA function in lhost package returns siba.RisingUnderway.

Jump to

Keyboard shortcuts

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