Files

65 lines
1.6 KiB
Markdown

# mailinabox-go
Go client library and CLI for the [Mail-in-a-Box](https://mailinabox.email/) admin DNS API.
Licensed under the [MIT License](LICENSE).
## Library
```go
import miab "gitea.koszewscy.waw.pl/koszewscy/mailinabox-go"
// Explicit credentials:
c, err := miab.NewClient("box.example.com", "admin@example.com", "password")
// From environment variables (MIAB_* or MAILINABOX_* style):
c, err := miab.NewClient("", "", "")
c.SetRecord("foo.example.com", "TXT", "v=spf1 ~all")
c.AddRecord("foo.example.com", "A", "1.2.3.4")
c.DeleteRecord("foo.example.com", "A", "1.2.3.4")
records, _ := c.ListRecords("TXT")
```
## CLI
Install from registry:
```sh
go install gitea.koszewscy.waw.pl/koszewscy/mailinabox-go/cmd/miab@latest
```
Build locally:
```sh
go build -o miab ./cmd/miab
```
Credentials via environment variables (either style is accepted):
```sh
# MIAB style
export MIAB_HOST=box.example.com
export MIAB_USERNAME=admin@example.com
export MIAB_PASSWORD=password
# Mail-in-a-Box style
export MAILINABOX_BASE_URL=https://box.example.com
export MAILINABOX_EMAIL=admin@example.com
export MAILINABOX_PASSWORD=password
```
Commands:
```sh
miab list [--type TXT]
miab set [--type TXT] foo.example.com "hello"
miab add [--type A] foo.example.com 1.2.3.4
miab delete [--type TXT] foo.example.com ["hello"]
```
## AI Disclaimer
This project was generated with the assistance of AI tools. While efforts have been made to ensure the accuracy and reliability of the code, users should review and test the code thoroughly before using it in production environments. The author is not responsible for any issues arising from the use of this code.