3.9. postfix

3.9.1. NAME

postfix - Guardian Digital WebTool module interface to the Postfix SMTP server.

3.9.2. SYNOPSIS

use postfix;
my $postfix  = new postfix;

3.9.3. DESCRIPTION

This Guardian Digital WebTool module provides an interface to manipulating the Postfix mail server. This module allows you to manage aliases, transports (mail routes), and virtual domains.

3.9.4. METHODS

is_installed()

This function is used to check postfix is installed or not.

Example Usage:

if (!$postfix->is_installed()){
.....
}

reload()

This function is used to reload the postfix(/etc/init.d/postfix) service.

Example Usage:

$postfix->reload();

readval($)

This function is used to get a specified configuration parameter's(argument) value of postfix mail system.

Example Usage:

$mailboxsizelimit = $postfix->readval("mailbox_size_limit");

readsmtp()

This function is used to determine if smtpd is enabled. If its enabled then returns 'yes' else 'no'.

Example Usage:

$enable_status = $postfix->readsmtp();

updatesmtp($)

This function is used to activate or deactivate smtpd service. It receives one argument, if argument is 'yes' then it will activate smtpd, if argument is 'no' it will deactivate smtpd.

Example Usage:

updatesmtp('yes');

setval($$)

This function is used to set specified option's value using postconf(/usr/sbin/postconf). It receivs two arguments(option and value).

Example Usage:

setval(undef, 'message_size_limit', 3200);

smtpd_rr_util($$)

This function inserts or removes a given entry from the Postfix smtpd_recipient_restrictions. The first argument is 'insert' or 'remove',and the second argument is the restriction you want to insert or remove.

Example Usage:

smtpd_rr_util(undef, 'insert', 'reject_unknown_sender_domain');

get_smtpd_rr_val()

This function reads value for restrictions of smtpd recipients, and depends on checking conditions it returns value 'strict', 'moderate' or 'off'.

Example Usage:

$restriction = $postfix->get_smtpd_rr_val();

config_write($)

This function writes a configuration depends on the user selected options. It receives hash reference containing all values(e.g. relayhost, enable-disable procmail, queue lifetime etc). Using setval function it sets all values according to options. additionaly depends on client restriction it applies suitable operations (insert,remove)too.

Example Usage:

$postfix->config_write($newopts);

get_domains()

This function reads through the /etc/postfix/virtual file, and returns an array of virtual mail domains.

Example Usage:

my @virtual_domains = $postfix->get_domains();

add_domains($$)

This function allows us to add an virtual mail domain by passing domain name and postmaster as argument.

Example Usage:

$postfix->add_domain($domain_name, $postmaster);

delete_domain($)

This function can be used to delete a virtual domain. Domain name is passed as an argument. It deletes corresponding relay domain too.

Example Usage:

$postfix->delete_domain($domain_name);

get_relaydomains()

This function can be used to get a array of relay domains. It filters out $mydestination (list of domains that this machine considers itself the final destination for)and $transport_maps.

Example Usage:

my @relays = get_relaydomains();

save_relaydomains(@)

This function receives an array of relay domains and save them(writes out in main.cf).

Example Usage:

save_relaydomains(@newrelays);

add_relaydomain($)

This function add a given relay domain to the pool of relay domains. It receives a domain name as an argument.

Example Usage:

add_relaydomain($domain_name);

delete_relaydomain($)

This function deletes a given relay domain. It receives a domain name as an argument.

Example Usage:

delete_relaydomain($domain_name);

get_mappings($)

This function can be used to get list of all addresses in a virtual domain(address, Recipient). It receives a domain name as an argument. It returns array of hash references. see example for detail.

Example Usage:

my @addresses = $postfix->get_mappings($domain);
$addresses[$j]->{index} = $index;
$addresses[$j]->{address} = $address;
$addresses[$j]->{recipient} = $recipient;

add_mapping($$$)

This function can be used to add an email(address,recipient) to a virtual domain. It receives a domain name, email address, and recipient as arguments.

Example Usage:

$postfix->add_mapping($domain_name, $email_address, $recipient);

delete_mapping($$$)

This function can be used to delete an email(address,recipient) from a virtual domain. It receives a domain name, address, and recipient as arguments.

Example Usage:

$postfix->delete_mapping($domain_name, $email_address, $recipient);

update_mapping($$$)

This function is used to update an email(address,recipient) in a virtual domain. It receives a domain name, address, and recipient as arguments.

Example Usage:

$postfix->update_mapping($domain_name, $email_address, $recipient);

rebuild_virtual_map()

This function can be used to rebuild virtual map in hash file using postmap utility.

Example Usage:

$postfix->rebuild_virtual_map();

parse_aliases($)

This function returns a hash reference containing all of the mail aliases that currently exist on the system. By default it will skip over "system" aliases that the end-user should never manipulate, but you can tell it to pass _all_ aliases back up by passing a single argument of 1 (true).

Example Usage:

my $aliases = $postfix->parse_aliases(1);

add_alias($$)

This function can be used to add an alias to aliases configuration file, alias and recipient values are passed as arguments.

Example Usage:

$postfix->add_alias($alias, $recipient);

update_alias($)

This function is used to update an alias entry in aliases configuration file, alias and recipient values are passed as arguments.

Example Usage:

$postfix->update_alias($alias, $recipient);

delete_alias($)

This function is used to delete an alias entry from aliases configuration file, alias value is passed as arguments.

Example Usage:

$postfix->delete_alias($alias);

get_alias_recipient($)

This function is used to get recipient for particular alias. Alias is passed as an argument. it returns corresponding recipient.

Example Usage:

my $recipient = $postfix->get_alias_recipient($alias);

resolve_alias($$)

This function takes an alias and a method (files) as its arguments and returns what the alias resolved to. Currently only the "files" method is defined.

Example Usage:

my @result = $postfix->resolve_alias($alias, 'files');

rebuild_alias_map()

This function can be used to rebuild alias map in hash file using postalias utility.

Example Usage:

$postfix->rebuild_alias_map();

get_transports()

This function can be used to make a hash using /etc/postfix/transport configuration file, which will contain domain and destination, respectively as key and value pair. Hash reference will be sent as a result.

Example Usage:

my $transports  = $postfix->get_transports();

add_transport($$)

This function is used to add an entry in /etc/postfix/transport configuration file. It receives domain name and destination as arguments.

Example Usage:

$postfix->add_transport($domain_name, $dest);

update_transport()

This function is used to update an entry in /etc/postfix/transport configuration file. It receives domain name and destination as arguments.

Example Usage:

$postfix->update_transport($domain_name, $dest);

delete_transport($)

This function is used to delete an entry from /etc/postfix/transport configuration file. It receives domain name as argument.It also deletes related relaydomain too.

Example Usage:

$postfix->delete_transport($domain_name);

rebuild_transport_map()

This function can be used to rebuild transport map in hash file using postmap utility.

Example Usage:

$postfix->rebuild_transport_map();

3.9.5. AUTHORS

Pax Dickinson <pax@guardiandigital.com>

3.9.6. COPYRIGHT AND LICENSE

Copyright Guardian Digital, Inc., All Rights Reserved