global::utils

Utility functions to interact with the system.

fn get_root_domain

fn get_root_domain(domain: SharedObject) -> String
fn get_root_domain(domain: String) -> String
details

Get the root domain (the registrable part)

Examples

foo.bar.example.com => example.com


fn hostname

fn hostname() -> String
details

Get the hostname of this machine.

Return

  • string - the host name of the machine.

Effective smtp stage

All of them.

Examples

#{
  connect: [
    rule "hostname" || {
      state::accept(`250 ${utils::hostname()}`);
    }
  ]
}

fn user_exist

fn user_exist(name: String) -> bool
fn user_exist(name: SharedObject) -> bool
details

Check if a user exists on this server.

Args

  • name - the name of the user.

Return

  • bool - true if the user exists, false otherwise.

Effective smtp stage

All of them.

Examples

#{
  connect: [
    rule "user_exist" || {
      state::accept(`250 root exist ? ${if utils::user_exist("root") { "yes" } else { "no" }}`);
    }
  ],
  mail: [
    rule "user_exist (obj)" || {
      state::accept(`250 ${utils::user_exist(ctx::mail_from())}`);
    }
  ]
}