
###########
MailAccount
###########


****
NAME
****


Kernel::System::MailAccount - to manage mail accounts


***********
DESCRIPTION
***********


All functions to manage the mail accounts.


****************
PUBLIC INTERFACE
****************


new()
=====


Don't use the constructor directly, use the ObjectManager instead:


.. code-block:: perl

     my $MailAccountObject = $Kernel::OM->Get('Kernel::System::MailAccount');



MailAccountAdd()
================


adds a new mail account


.. code-block:: perl

     my $MailAccountID = $MailAccount->MailAccountAdd(
         Login               => 'mail',
         Password            => 'SomePassword',
         Host                => 'pop3.example.com',
         Type                => 'POP3',
         IMAPFolder          => 'Some Folder',       # optional, only valid for IMAP-type accounts
         ValidID             => 1,
         Trusted             => 0,
         AuthenticationType  => 'oauth2_token',      # optional; defaults to 'password'
         OAuth2TokenConfigID => 2,                   # optional
         DispatchingBy       => 'Queue',             # Queue|From
         QueueID             => 12,
         UserID              => 123,
     );


Returns:


.. code-block:: perl

     my $MailAccountID = 1;



MailAccountGetAll()
===================


returns an array of all mail account data


.. code-block:: perl

     my @MailAccounts = $MailAccount->MailAccountGetAll();


Returns:


.. code-block:: perl

     my @MailAccount = (
         [
             ID                  => 123,
             Login               => 'mail',
             Password            => 'SomePassword',
             Host                => 'pop3.example.com',
             Type                => 'POP3',
             QueueID             => 1,
             IMAPFolder          => 'Some Folder',
             Trusted             => 0,
             Comment             => 'Comment',
             ValidID             => 1,
             AuthenticationType  => 'oauth2_token',
             OAuth2TokenConfigID => 2,
             CreateTime          => '16-04-2016 12:34:56',
             ChangeTime          => '16-04-2016 12:34:56',
         ],
         [
             # ...
         ]
     );



MailAccountGet()
================


returns a hash of mail account data


.. code-block:: perl

     my %MailAccount = $MailAccount->MailAccountGet(
         ID => 123,
     );


Returns:


.. code-block:: perl

     my %MailAccount = (
         ID                  => 123,
         Login               => 'mail',
         Password            => 'SomePassword',
         Host                => 'pop3.example.com',
         Type                => 'POP3',
         QueueID             => 1,
         IMAPFolder          => 'Some Folder',
         Trusted             => 0,
         Comment             => 'Comment',
         ValidID             => 1,
         AuthenticationType  => 'oauth2_token',
         OAuth2TokenConfigID => 2,
         CreateTime          => '16-04-2016 12:34:56',
         ChangeTime          => '16-04-2016 12:34:56',
     );



MailAccountUpdate()
===================


update a new mail account


.. code-block:: perl

     my $Success = $MailAccount->MailAccountUpdate(
         ID                  => 1,
         Login               => 'mail',
         Password            => 'SomePassword',
         Host                => 'pop3.example.com',
         Type                => 'POP3',
         IMAPFolder          => 'Some Folder',   # optional, only valid for IMAP-type accounts
         ValidID             => 1,
         Trusted             => 0,
         AuthenticationType  => 'oauth2_token',  # optional; defaults to 'password'
         OAuth2TokenConfigID => 2, # optional
         DispatchingBy       => 'Queue',         # Queue|From
         QueueID             => 12,
         UserID              => 123,
     );


Returns:


.. code-block:: perl

     my $Success = 1;



MailAccountDelete()
===================


deletes a mail account


.. code-block:: perl

     $MailAccount->MailAccountDelete(
         ID => 123,
     );



MailAccountList()
=================


returns a list (Key, Name) of all mail accounts


.. code-block:: perl

     my %List = $MailAccount->MailAccountList(
         Valid => 0, # just valid/all accounts
     );



MailAccountBackendList()
========================


returns a list of usable backends


.. code-block:: perl

     my %List = $MailAccount->MailAccountBackendList();



MailAccountFetch()
==================


fetch emails by using backend


.. code-block:: perl

     my $Ok = $MailAccount->MailAccountFetch(
         Login         => 'mail',
         Password      => 'SomePassword',
         Host          => 'pop3.example.com',
         Type          => 'POP3',    # POP3,POP3s,IMAP,IMAPS
         Trusted       => 0,
         DispatchingBy => 'Queue',   # Queue|From
         QueueID       => 12,
         CMD           => 1, # optional: Print additional output of MailAccount module to STDOUT
         UserID        => 123,
     );



MailAccountCheck()
==================


Check inbound mail configuration


.. code-block:: perl

     my %Check = $MailAccount->MailAccountCheck(
         Login    => 'mail',
         Password => 'SomePassword',
         Host     => 'pop3.example.com',
         Type     => 'POP3',             # POP3|POP3S|IMAP|IMAPS
         Timeout  => '60',
         Debug    => '0',
     );



GetAuthenticationTypes()
========================


Returns the available authentication types.


.. code-block:: perl

     my %AuthenticationTypes = $MailAccountObject->GetAuthenticationTypes();


Returns:


.. code-block:: perl

     my %AuthenticationTypes = (
         # authentication type => name
         password              => 'Password',
         oauth2_token          => 'OAuth2 token',
     );





