MailRelayExtensions

Customer-builder sugar for declaring an outbound mail smarthost. Adds a User to DirectoryService.Users tagged with MailRelay; the relay endpoint is encoded in the Email field as relay@<host>[:<port>]. NixTemplateFactory.BuildRelayFromUsers picks it up at template-render time.

public static class MailRelayExtensions

1. Methods

1.1. AddMailRelay(NETSetupConfig, string, string, SecretString, int)

Declare an outbound SMTP smarthost. Mail VM postfix gets relayhost = [host]:port and SASL credentials (saslUser/saslPassword).

public static NETSetupConfig AddMailRelay(this NETSetupConfig config, string host, string saslUser, SecretString saslPassword, int port = 587)
Table 1. Parameters
Name Type Description

config

NETSetupConfig

Customer config the relay user is attached to.

host

string

Smarthost FQDN (e.g. smtp.gmail.com).

saslUser

string

SASL username (often a full email address).

saslPassword

SecretString

SASL password.

port

int

Submission port. Default 587.

Returns: NETSetupConfig — The config (fluent).

1.2. AddMailRelayViaCert(NETSetupConfig, string, int)

Declare an outbound smarthost authenticated by the mail VM’s TLS *client certificate* (no SASL) - the Microsoft 365 "inbound connector, certificate" method. Sets config.MailRelay directly (POCO path, no credential user) with UseClientCert = true. Requires a publicly-trusted cert on the mail VM (real Let’s Encrypt) whose subject matches the domain the M365 connector expects.

public static NETSetupConfig AddMailRelayViaCert(this NETSetupConfig config, string host, int port = 25)
Table 2. Parameters
Name Type Description

config

NETSetupConfig

Customer config.

host

string

Connector endpoint FQDN (e.g. tenant.mail.protection.outlook.com).

port

int

Relay port. Default 25 (connector).

Returns: NETSetupConfig — The config (fluent).