---
name: "dns_mx"
section: "3"
platform: "linux"
package: "libowfat-dev"
version: "0.32-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/dns_mx"
---

# dns\_mx(3)

look up Mail eXchanger

## NAME

dns\_mx - look up Mail eXchanger

## SYNTAX

**#include \<libowfat/dns.h\>**

int **dns\_mx**(stralloc\* *out*,stralloc\* *fqdn*);

## DESCRIPTION

dns\_mx looks up MX records for the fully-qualified domain name in *fqdn*. It puts the MX records into *out* and returns 0. Each MX record is a two-byte MX distance (big endian) followed by a \\0-terminated dot-encoded domain name. If the domain does not exist in DNS, or has no MX records, *out* will be empty.

If dns\_mx has trouble with the DNS lookup or runs out of memory, it returns -1, setting errno appropriately. It may or may not change *out*.

## SEE ALSO

[dns\_mx\_packet(3)](/dns_mx_packet/3.md), [dns\_ip4(3)](/dns_ip4/3.md), [dns\_ip6(3)](/dns_ip6/3.md)
