The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

XMail::Ctrl - Crtl access to XMail server

www.xmailserver.com

VERISON

version 1.4 of XMail::Ctrl

released 08/21/2002

SYNOPSIS

        use XMail::Ctrl;
        my $XMail_admin      = "aaron.johnson";
        my $XMail_pass       = "mypass";
        my $XMail_port       = "6017";
        my $XMail_host       = "aopen.hank.net";
        my $test_domain      = "aopen.hank.net";
        my $test_user        = "rick";
                
        my $xmail = XMail::Ctrl->new( 
                    ctrlid   => "$XMail_admin",
                                ctrlpass => "$XMail_pass",
                                port     => "$XMail_port",
                                host     => "$XMail_host" 
                        ) or die $!;
        
        my $au = $xmail->useradd( 
                {
                    username => "$test_user",
                            password => 'test',
                            domain   => "$test_domain",
                            usertype => 'U' 
                        }
                        );
        
        # setting the mailproc.tab

    my $proc = $xmail->usersetmproc(
            {
                username       => "$test_user",
                            domain         => "$test_domain",
                            output_to_file => "command for mailproc.tab",

                        }
                         );
        
        $xmail->quit;

DESCRIPTION

This module allows for easy access to the Crtl functions for XMail. It operates over TCP/IP so it can be used to communicate with either Windows or Linux based XMail servers.

The code was written on a Win32 machine and has been tested on Mandrake and Red Hat Linux as well with Perl version 5.6

Overview

All commands take the same arguments as outlined in the XMail documentation. All commands are processed by name and arguments can be sent in the any order. As is outlined above in the useradd statement.

The command structure for XMail allows a fairly easy interface to the command set. This module has NO hardcoded xmail methods. As long as the current ordering of commands is followed in the XMail core the module should work to any new commands unchanged.

The "method" that you pass is automagicly (AUTOLOAD) turned into a part of the arguments you are sending into the object.

That is when you call $xmail->useradd( \%args );

It is passed to the xcommand method as a hash with the "method" you called added to the %args, so $args{command} would equal useradd in this case. You can pass args in any order due to XMails consistent ordering of ctrl variables. The commands are always in the same order. So we loop through the array of variables in the order XMail expects them and add them to the "command" if a corresponding %args value is present. Please see the source for more information.

Any command that accepts vars can use the following:

To send uservarsset add a vars anonymous hash, such as:

        $xmail->uservarsset( {
        domain   => 'aopen.hank.net',
        username => 'rick',
        vars     => { 
                RealName      => 'Willey FooFoo',
                RemoteAddress => '300.000.000.3',
                VillageGrid   => '45678934' 
                } 
        } );

The ".|rm" command can used as described in the XMail docs.

Lists

Lists are now returned as an array reference unless you set the raw_list method to true.

    $xmail->raw_list(1);

To print the lists you can use a loop like this:

    my $list = $xmail->userlist( { domain => 'yourdomin.net' } );
    foreach my $row (@{$list}) {
        print join("\t",@{$row}) . "\n";        
    }

Refer to the XMail documentation for each command for information on which columns will be returned for a particular command.

BUGS

Possible problems dealing with wild card requests. I have not tested this fully. Please send information on what you are attempting if you feel the module is not providing the correct function.

AUTHOR

Aaron Johnson solution@gina.net

THANKS

Thanks to Davide Libenzi for a sane mail server with an incredibly consistent interface for external control.

Thanks to Mark-Jason Dominus for his wonderful classes at the 2000 Perl University in Atlanta, GA where the power of AUTOLOAD was revealed to me.

Thanks to my Dad for buying that TRS-80 in 1981 and getting me addicted to computers.

Thanks to my wife for leaving me alone while I write my code :^)

Thanks to Oscar Sosa for spotting the lack of support for editing the 'tab' files

CHANGES

1.4 - Modified/corrected documenation

1.3 - Added support for list commands to return referenced array of arrays instead of text string.

1.2 - Added support for the usersetmproc command

1.0 - Initial release

COPYRIGHT

Copyright (c) 2000,2001,2002 Aaron Johnson. All rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.