Manage Cloudflare Email Service sending subdomains.
Sending subdomains are scoped to a zone, so every function takes the zone_id
as its first argument. The config keyword list is the same as the mailer's;
only :api_token is required (:account_id is not used here), and
:base_url and :req_options are honoured as usual.
config = Application.get_env(:my_app, MyApp.Mailer)
zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
{:ok, subdomains} = SwooshCloudflare.Subdomains.list(zone_id, config)
{:ok, subdomain} = SwooshCloudflare.Subdomains.create(zone_id, "send.example.com", config)
{:ok, subdomain} = SwooshCloudflare.Subdomains.get(zone_id, subdomain["tag"], config)
{:ok, _} =
SwooshCloudflare.Subdomains.update(zone_id, subdomain["tag"], config,
drop_suppressed_recipients: true,
preview_enabled: false
)
{:ok, records} = SwooshCloudflare.Subdomains.dns_records(zone_id, subdomain["tag"], config)
{:ok, _} = SwooshCloudflare.Subdomains.delete(zone_id, subdomain["tag"], config)The id argument is the subdomain "tag" returned by Cloudflare.
Subdomains are returned as decoded from Cloudflare, with string keys
("tag", "name", "enabled", "created", "modified", "dkim_selector",
"return_path_domain", "drop_suppressed_recipients", "preview_enabled").
The API token needs permission to edit the zone's Email Sending settings.
Errors use the same shapes as the mailer: {:error, {status, reason, body}},
{:error, {429, :rate_limited, retry_after}}, or a network error term.
Summary
Functions
Creates a sending subdomain with the given name (for example "send.example.com").
Deletes a sending subdomain by id.
Fetches the DNS records required to verify a sending subdomain.
Fetches a single sending subdomain by id.
Lists the sending subdomains of a zone.
Updates a sending subdomain.
Types
Functions
Creates a sending subdomain with the given name (for example "send.example.com").
Deletes a sending subdomain by id.
Fetches the DNS records required to verify a sending subdomain.
Returns {:ok, [record]} with each record decoded with string keys.
Fetches a single sending subdomain by id.
Lists the sending subdomains of a zone.
Updates a sending subdomain.
Options (only given ones are sent): :drop_suppressed_recipients and
:preview_enabled, both booleans.