ZConf::Mail - Misc mail client functions backed by ZConf.
Version 2.0.0
use ZConf::Mail; my $zcmail = ZConf::Mail->new(); ...
Any time you see account name or account, referenced outside of 'createAccount', it means that it should also include the type as well. So for a POP3 account named 'test' it would be 'pop3/test'.
This initiates the module. The one arguement is accepted and it is a hash.
This can be allows one to pass ZConf a specific set of arguements to be initialized with.
Checks to make sure a accont exists. One arguement is taken and that is the account name.
if($zcmail->accountExists('pop3/foo)){ print "pop3/foo does exist"; }
This connects Mail::IMAPTalk connection to a IMAP account.
#connects to the IMAP account 'imap/foo' my $imap=$zcmail->connectIMAP('imap/foo'); if($zcmail->error)( warn('Error:'.$zcmail->error.': '.$zcmail->errorString); )
Creates a new Mail::Box::Maildir object for accessing the maildir.
#connects to the maildir account 'maildir/foo' my $imap=$zcmail->connectMaildir('maildir/foo'); if($zcmail->error)( warn('Error:'.$zcmail->error.': '.$zcmail->errorString); )
Creates a new Mail::Box::Mbox object for accessing the mbox.
#connects to the mbox account 'mbox/foo' my $imap=$zcmail->connectMbox('mbox/foo'); if($zcmail->error)( warn('Error:'.$zcmail->error.': '.$zcmail->errorString); )
This connects Mail::POP3Client connection to a POP3 account.
#connects to the mbox account 'pop3/foo' my $imap=$zcmail->connectPOP3('pop3/foo'); if($zcmail->error)( warn('Error:'.$zcmail->error.': '.$zcmail->errorString); )
#connects to the SMTP account 'smtp/foo' my $imap=$zcmail->connectSMTP('smtp/foo'); if($zcmail->error)( warn('Error:'.$zcmail->error.': '.$zcmail->errorString); )
This creates a new account. The only arguement accepted, and required, is a hash. More information can be found below.
The required variables for a account can be found in the VARIABLES section. Those listed below are also required by this function.
The two common ones are 'type' and 'account'. You should consult 'VARIABLES' for the various posibilities for each account type.
This is the type of a account it is. It is always lower case as can be seen in the variables section.
This is the name of the account. It will be appended after the account type. Thus for the account 'pop3/some account name' it will be 'some account name'.
#adds a POP3 server $zcmail->createAccount({type=>'pop3', account=>'some account name', user=>'monkey', pass=>'ape', auth=>'auto', useSSL=>'0', SSLoptions=>'', deliverTo=>'', fetchable=>'0', server=>'127.0.0.1', }); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
Creates a new Email::Simple object.
This is the account is being setup for. If this is not specified, the default one is used.
An array of To addresses.
An array of CC addresses.
The subject of the message.
The body of the message.
This create a new MIME::Lite object.
This will also sign it if needed be.
The three following are required.
account subject body
This is the account is being setup for. If no account is specified, the default on is used.
An array of files to attach.
This will set the in-reply-to header value.
If is set to true and the account is set to sign by default, it won't be.
When created, call the quiet method.
This defaults to on as it will throw errors when doing GPG signing.
This sets the default sendable email address.
my $defaultFetchable=$zcmail->defaultFetchableGet; if(!defined($defaultFetchable)){ print "There is no default sendable account.\n"; } print $defaultFetchable."\n";
This sets the default fetchable account.
$zcmail->defaultFechableSet('smtp/foo'); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
This sets the default sendable email account.
my $defaultSendable=$zcmail->defaultSendableGet; if(!defined($defaultSendable)){ print "There is no default sendable account.\n"; } print $defaultSendable."\n";
$zcmail->defaultSendableSet('smtp/foo'); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
This gets what the default IMAP account is.
This is used for removed a account. One option is taken and that is the name of the account.
#removes the account 'mbox/foo' $zcmail->delAccount('mbox/foo'); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
This checks if a acocunt is deliverable or not.
#check to see if the account is a account that can be delivered to if(!zcmail->deliverable('exec/foo')){ print "Not deliverable."; }
This is a wrapper function to the other deliver functions. This is a wrapper to the other delivery functions.
The first arguement is the account. The second is the message. The third is the a hash that some deliver types optionally use.
This can be used to specify a folder to deliver to. If it is not defined, it will try to use what ever is the inbox for that account.
Currently this is only used by IMAP.
#delivers the mail contained in $mail to 'exec/foo' $zcmail->deliver('exec/foo', $mail); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); } #delivers the mail contained in $mail to 'imap/foo' to the 'foo.bar' $zcmail->deliver('imap/foo', $mail, {folder=>'foo.bar'}); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
This is a delivers to a exec account.
It is generally not best to call it directly, but to let the deliver function route it. This allows for more flexible delivery.
The first arguement is the account. The second is the message. The third is the a optional args hash.
#delivers the mail contained in $mail to 'exec/foo' $zcmail->deliverExec('exec/foo', $mail); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
This is a delivers to a IMAP account.
#delivers the mail contained in $mail to 'imap/foo' to the inbox $zcmail->deliverIMAP('imap/foo', $mail); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); } #delivers the mail contained in $mail to 'imap/foo' to the 'foo.bar' $zcmail->deliverIMAP('imap/foo', $mail, {folder=>'foo.bar'}); if($zcmail->{error}){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
This is a wrapper function for the other accounts. The only accepted arg is account name. If no account is specified, the default one is used.
It is then delivered to the account specified by variable 'deliverTo' for the account.
#fetches the mail for 'pop3/foo' $zcmail->fetch('pop3/foo'); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
This checks if a account is fetchable or not. The reason for the existance it to make some things look neater.
Fetches the messages from the inbox of a IMAP account.
my $number=$mail->fetchIMAP('imap/foo'); if($mail->error}){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }else{ print 'Fetched '.$number."messages.\n"; }
Fetches the messages from the inbox of a maildir account.
my $number=$mail->fetchMaildir('maildir/foo'); if($mail->{error}}){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }else{ print 'Fetched '.$number."messages.\n"; }
Fetches the messages from the inbox of a mbox account.
my $number=$mail->fetchMbox('mbox/foo'); if($mail->{error}}){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }else{ print 'Fetched '.$number."messages.\n"; }
Fetches the messages from the inbox of a POP3 account.
my $number=$mail->fetchPOP3('pop3/foo'); if($mail->{error}}){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }else{ print 'Fetched '.$number."messages.\n"; }
Automatically format a chunk of text against various settings, primarily line wrapping.
$text=$zcmail->formatter($text); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
Get all options for the formatter.
my %formatterOptions=$zcmail->formatterGetAll; if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }else{ print 'marginLeft:'.formatterOptions{marginLeft}."\n". 'marginRight:'.formatterOptions{marginRight}."\n". 'squeeze:'.formatterOptions{squeeze}."\n". 'ignore:'.formatterOptions{ignore}."\n". 'justify:'.formatterOptions{justify}."\n". 'tabspace:'.formatterOptions{tabspace}."\n"; }
Set some options for the formatter.
Two arguments are required.
The first is the option to operate on.
The second is the value. A value of undef will result it being removed, there for the default being used when formatterGetAll is called.
#set the text justification to the right $zcmail->formatterSet('justify', 'right'); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); } #set the text justification back to the default $zcmail->formatterSet('justify', undef); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
Gets a array of the various accounts.
my @accounts=$zcmail->getAccounts; if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
This gets the various variables for a account, with 'accounts/*/*/' removed.
One arguement is required and that is the account name.
#get the account args for 'pop3/foo' my %args=$zcmail->getAccountArgs('pop3/foo'); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
This gets what the current set is.
my $set=$zcmail->getSet; if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
This is used for initiating the config used by ZConf.
$zcmail->init; if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
This lists the available sets.
my @sets=$zcmail->listSets; if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
Modifies a account.
Outside of account type, the rest are variables that will be changed.
This reads a specific set. If the set specified is undef, the default set is read.
#read the default set $zcmail->readSet(); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); } #read the set 'someSet' $zcmail->readSet('someSet'); if($zcmail->error){ warn('Error:'.$zcmail->error.': '.$zcmail->errorString); }
This sends a email. One arguement is accepted and that is a hash.
This is the account it is sending for. If this is not specified, the default sendable account is used.
This is a array of to addresses.
This is a array of cc addresses.
This is a array of bcc addresses.
This is the raw mail message to send.
This will override if a sent message will be saved or not.
Checks to see if a sendable.
#checks to see if 'smtp/foo' is sendable if(!$zcmail->sendable('smtp/foo')){ print 'not sendable' }
This signs the body.
There are three required arguements. The first is the account name it will be sending from. The second the body of the email. The third is the to address.
Returns the current error code and true if there is an error.
If there is no error, undef is returned.
if($zconf->error){ warn('error: '.$zconf->error.":".$zconf->errorString); }
This blanks the error storage and is only meant for internal usage.
It does the following.
$self->{error}=undef; $self->{errorString}="";
Returns the error string if there is one. If there is not, it will return ''.
In the various sections below, '*' is used to represent the name of a account. Account names can't match the following.
undef /\// /^\./ /^ / / $/ /\.\./
This is the username for a POP3 account.
This is the password for a POP3 account.
If set to a boolean value of true, SSL will be used.
This is the account to deliver to.
This is the folder in the account to deliver to.
If this account should be considered fetchable. If this flag is set, this will not be fetched my 'Mail::ZConf::Fetch'.
This is the auth type to use with the POP3 server.
The POP3 server to use.
The port on the server to use.
Any thing under here under here is a IMAP account.
This is the username for a IMAP account.
This is the password for a IMAP account.
If this account should be considered fetchable. If this flag is set, this will not be fetched my 'ZConf::Mail::Fetch', not written yet.
This should be set if you are planning on using it for storage.
This is the inbox that the mail should be delivered to.
The IMAP server to use.
This is the MBOX file to use.
This is the username for a SMTP account.
This is the password for a SMTP account.
This is the auth type to use with the SMTP server.
The SMTP server to use.
The from address to use for a account.
The name that will be used with the account.
This is the account to save it to. If it not defined or blank, it will not saved.
This is the folder to save it to for the account.
The time out for connecting to the server.
If PGP should be used or not for this account. This is a Perl boolean value.
Clear sign the message.
Attach the signature as a attachment.
Sign and encrypt the message. Not yet implemented.
The PGP key to use.
The digest algorithym to use. It will default to 'SHA512' if not specified.
To find what out what your version supports, run 'gpg --version'.
This is the command to execute for delivering a mail message. A single message will be delivered at a time by running the specified program and piping the message into it. Only a single message is delivered at once.
A example would be setting this to '/usr/local/libexec/dovecot/deliver' to deliver a message one's dovecot account.
This is the left margin. The default is zero if this is not defined.
This is the right margin. The default is 72 if this is not defined.
Removes unneeded whitespace. This is on by default.
Don't reformat any paragraph that matches this line. The default is '^[ \t]'.
How to justify the text. The default is left.
This is the default spaces per tab. The default is '4'.
This is the default sendable account. If this key does not exist or set to '', there is no default sendable account.
This is the default fetchable account. If this key does not exist or set to '', there is no default fetchable account.
If this is false, '$zcmail->init' needs run.
This hashes which contains the legal values for each type in a array. So for SMTP, '$zcmail->{legal}{smtp}' contains the array of legal values for SMTP.
This hashes which contains the required values for each type in a array. So for SMTP, '$zcmail->{required}{smtp}' contains the array of required values for SMTP.
This contains a array of fetchable account types.
This contains a array of deliverable account types.
This contains a array of sendable account types.
If any funtion errors, the error code is writen to '$zcmail->{error}', a error message is printed to stderr, and a short description is put in '$zcmail->{errorString}'.
When no error is present '$zcmail->{error}' is false, specifically undef.
Could not create the config.
No account type specified.
Unknown account type specified.
Illegal account name.
A required variable is not defined.
Account does not exist.
Authenticating with the POP3 server failed.
Connecting to the POP3 server failed.
Failed to either connect to IMAP server or authenticate with it.
Failed to connect to SMTP server.
Failed to authenticate with the SMTP server.
Failed to send the from for the SMTP session.
Failed to authenticate or connect to the SMTP server.
Failed to access maildir.
Account is not fetchable.
Failed to connect to POP3.
POP3 fetch failed.
Failed to read a ZConf config.
Wrong account type.
IO::MultiPipe error. See the error string for detains on it.
Mbox message delete failed.
Mbox fetch failed.
IMAP folder select failed.
Account is not a sendable account type.
No To or CC defined.
Failed to send a To, CC, or BCC address.
Failed to start the data session.
Failed to send the data.
Failed to end the data session.
Failed to quit.
Failed to create a Email::Simple object.
The account has one or more missing variables.
No INBOX specified for the IMAP account.
Failed to selected IMAP folder.
Failed to append to the IMAP folder.
ZConf error.
'saveTo' is not enabled for this account. This means it is either undefined or set to ''.
File does not exist.
Failed to create temporary directory for signing.
Failed to create temprorary body file for signing.
No pgpType is not specified.
PGPGkey is not specified.
Sign type is not valid.
Signing failed.
The specified option is not a valid option.
Zane C. Bowers, <vvelox at vvelox.net>
<vvelox at vvelox.net>
Please report any bugs or feature requests to bug-zconf-mail at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ZConf-Mail. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-zconf-mail at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc ZConf::Mail
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=ZConf-Mail
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/ZConf-Mail
CPAN Ratings
http://cpanratings.perl.org/d/ZConf-Mail
Search CPAN
http://search.cpan.org/dist/ZConf-Mail
Copyright 2008 Zane C. Bowers, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install ZConf::Mail, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ZConf::Mail
CPAN shell
perl -MCPAN -e shell install ZConf::Mail
For more information on module installation, please visit the detailed CPAN module installation guide.