# Postfix(Text)Resp

Once your `Handle()` method finished the **pps** [Handler](/api/handler.md) interfaces expects it to return a response code, so it can tell Postfix what to do with the mail in question. The [PostfixResp](/api/postfixresp.md) and the [PostifxTextResp](/api/postfixresp.md) types define all responses that Postfix accepts and the **pps** package supports.

Please check the [Postfix documentation](http://www.postfix.org/access.5.html) 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.

{% tabs %}
{% tab title="Signature" %}

```go
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"
)
```

{% endtab %}

{% tab title="Example" %}

```go
func Handle(ps *pps.PolicySet) pps.PostfixResp {
    fmt.Println("Postfix received a mail for:", ps.Recipient)
    return pps.RespDunno    
}
```

{% endtab %}
{% endtabs %}

### PostfixTextResp

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 [Custom responses](/api/postfixresp.md#custom-responses) functions.

{% tabs %}
{% tab title="Siganture" %}

```go
type PostfixTextResp string

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

{% endtab %}
{% endtabs %}

## 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.

{% tabs %}
{% tab title="Signature" %}

```go
func TextResponseOpt(PostfixResp, string) PostfixResp
```

{% endtab %}

{% tab title="Example" %}

```go
custResp := pps.TextResponseOpt(pps.RespDunno, "custom text")
```

{% endtab %}
{% endtabs %}

### 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.

{% tabs %}
{% tab title="Signature" %}

```go
func TextResponseNonOpt(PostfixTextResp, string) PostfixResp
```

{% endtab %}

{% tab title="Example" %}

```go
custResp := pps.TextResponseNonOpt(pps.TextRespFilter, "custom:filter")
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pps-docs.pebcak.de/api/postfixresp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
