Mail::vpopmail - Utility to get information about vpopmail managed email addresses
use Mail::vpopmail;
my $vchkpw = Mail::vpopmail->new();
my $vchkpw = Mail::vpopmail->new(cache => 1, debug => 0, auth_module => 'cdb', dsn => 'DBI:mysql:host=localhost;database=vpopmail', dbun => 'vpopmailuser', dbpw => 'vpoppasswd', );
Mail::vpopmail provides serveral functions for interacting with vpopmail. This module can be useful especially when hashing is turned on, as you can not predict the location of the domain's nor the mailbox's directories.
Mail::vpopmail
OPTIONS are passed in a hash like fashion, using key and value pairs. Possible options are:
OPTIONS
cache - Cache results of queries (0=Off, 1=On). Default=On.
debug - Print debugging info to STDERR (0=Off, 1=On). Default=On.
auth_module - cdb or sql. Default=cdb, but Default=sql if ~vpopmail/etc/vpopmail.mysql exists.
dsn - SQL DSN. Default='DBI:mysql:host=localhost;database=vpopmail' Autogenerated if ~vpopmail/etc/vpopmail.mysql exists.
dbun - SQL Username. Default=vpopmailuser. Autogenerated if ~vpopmail/etc/vpopmail.mysql exists.
dbpw - SQL Password. Default=vpoppasswd. Autogenerated if ~vpopmail/etc/vpopmail.mysql exists.
email - the email address to get properties on
field - the field(s) to be returned (may be comma separated):
dir - return this domain's vpopmail domains directory crypt - return the encrypted password uid - return the uid gid - return the gid comment - return the comment, if available maildir - return this user's maildir quota - return the quota (you have to parse this yourself) plain - return the plain text password, if available
domain - the domain to get properties on
field - the field to be returned:
dir - return the vpopmail domain directory mailboxes - return an array reference containing all the mailboxes all - return an array ref of hash refs of all data for the domain
name - returns an array reference of the names of all domains dir - returns an array refrence of all domain directories map - returns a hash reference of domain name -> domain directory
use strict; use Mail::vpopmail; my $vchkpw = Mail::vpopmail->new(cache=>1, debug=>0); # find all domains my $domains_aref = $vchkpw->alldomains(field => 'name'); foreach my $domain (@${domains_aref}){ print "$domain\n"; } # find all domains directories my $dirlist_aref = $vchkpw->alldomains(field => 'dir'); foreach my $dir (@${dirlist_aref}){ print "$dir\n"; } # find all domains and their directories my $alllist_aref = $vchkpw->alldomains(field => 'map'); foreach my $href (@${alllist_aref}){ print "$href->{name} => $href->{dir}\n"; } my $domain = shift; unless(defined($domain)){ print "enter domain: "; chop($domain=<STDIN>); } # find all mailboxes in a given domain my $mailboxes_aref = $vchkpw->domaininfo(domain => $domain, field => 'mailboxes'); foreach my $mailbox (@{$mailboxes_aref}){ print "found mailbox: $mailbox for domain: $domain\n"; } # find all properties for a given domain my $alldata_aref = $vchkpw->domaininfo(domain => $domain, field => 'all'); foreach my $href (@{$alldata_aref}){ print "found data for $domain:\n"; while(my($key,$value) = each %{$href}){ print " found $key => $value\n"; } } # individual user stuff my $email = shift; unless(defined($email)){ print "email address: "; chop($email=<STDIN>); } my $dir = $vchkpw->userinfo(email => $email, field => 'dir'); print "dir: $dir\n"; my ($crypt,$uid,$gid) = $vchkpw->userinfo(email => $email, field => 'crypt,uid,gid'); print "crypt/uid/gid: $crypt/$uid/$gid\n"; my $comment = $vchkpw->userinfo(email => $email, field => 'comment'); print "comment: $comment\n"; my $maildir = $vchkpw->userinfo(email => $email, field => 'maildir'); print "maildir: $maildir\n"; my $quota = $vchkpw->userinfo(email => $email, field => 'quota'); print "quota: $quota\n"; my $plain = $vchkpw->userinfo(email => $email, field => 'plain'); print "plain: $plain\n";
This version is the first that supports SQL auth modules. It is not tested and should be used with caution. Feedback needed.
Jeremy Kister - http://jeremy.kister.net/
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install Mail::vpopmail, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mail::vpopmail
CPAN shell
perl -MCPAN -e shell install Mail::vpopmail
For more information on module installation, please visit the detailed CPAN module installation guide.