📩
postfix-policy-server
  • 👋Welcome
  • API
    • 🚀Server
    • 📋ServerOpt
    • 📐Handler
    • 🗃️PolicySet
    • 📣Postfix(Text)Resp
  • Code Examples
    • 💡Policy to JSON echo server
Powered by GitBook
On this page
  • PostfixResp
  • PostfixTextResp
  • Custom responses
  • TextResponseOpt
  • TextResponseNonOpt
  1. API

Postfix(Text)Resp

Possible responses for the Postfix server

PreviousPolicySetNextPolicy to JSON echo server

Last updated 3 years ago

Once your Handle() method finished the pps interfaces expects it to return a response code, so it can tell Postfix what to do with the mail in question. The and the types define all responses that Postfix accepts and the pps package supports.

Please check the on the details of the various responses.

PostfixResp

The PostfixResp type defines all possible respones to Postfix that do not require any type additional text appended to it. Any of these can be directly used as return value in your Handle() method.

type PostfixResp string

const (
	RespOk            PostfixResp = "OK"
	RespReject        PostfixResp = "REJECT"
	RespDefer         PostfixResp = "DEFER"
	RespDeferIfReject PostfixResp = "DEFER_IF_REJECT"
	RespDeferIfPermit PostfixResp = "DEFER_IF_PERMIT"
	RespDiscard       PostfixResp = "DISCARD"
	RespDunno         PostfixResp = "DUNNO"
	RespHold          PostfixResp = "HOLD"
	RespInfo          PostfixResp = "INFO"
	RespWarn          PostfixResp = "WARN"
)
func Handle(ps *pps.PolicySet) pps.PostfixResp {
    fmt.Println("Postfix received a mail for:", ps.Recipient)
    return pps.RespDunno    
}

PostfixTextResp

type PostfixTextResp string

const (
	TextRespFilter   PostfixTextResp = "FILTER"
	TextRespPrepend  PostfixTextResp = "PREPEND"
	TextRespRedirect PostfixTextResp = "REDIRECT"
)

Custom responses

As already mentioned, the PostfixResp type responses do not require any additional information appended to, but most of those reponses allow it. For the PostfixTextResp types the additional information is non-optional. pps provides methods to create custom responses with both of these types.

TextResponseOpt

The TextResponseOpt() method allows you to append custom text to your PostfixResp type responses. It will return a valid PostfixResp type that can be used as return value in your Handle() method.

func TextResponseOpt(PostfixResp, string) PostfixResp
custResp := pps.TextResponseOpt(pps.RespDunno, "custom text")

TextResponseNonOpt

With the TextResponseNonOpt() method you can make use of the PostfixTextResp type responses and create a valid PostfixResp type with it, that can be used as return value for your Handle() method.

func TextResponseNonOpt(PostfixTextResp, string) PostfixResp
custResp := pps.TextResponseNonOpt(pps.TextRespFilter, "custom:filter")

The PostfixTextResp type defines those kind of responses that require to have additional information appended to it. These types cannot be directly used as return value in your Handle() function but need to be converted to a PostfixResp type first using the functions.

📣
Handler
PostfixResp
PostifxTextResp
Postfix documentation
Custom responses