Kernel::System::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:

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

MailAccountAdd()

adds a new mail account

    $MailAccount->MailAccountAdd(
        CredentialID     => '...',
        Host             => 'pop3.example.com',
        Type             => 'POP3',
        IMAPFolder       => 'Some Folder', # optional, only valid for IMAP-type accounts
        ValidID          => 1,
        Trusted          => 0,
        SSLVerify        => 0,             # optional, available for secure type account
        SSLFingerprint   => '',            # optional, SSLFingerprint hash if SSLVerify is enabled
        SSLVerifyCN_Name => '',            # optional, SSLVerifyCN_Name if SSLVerify is enabled
        DispatchingBy    => 'Queue',       # Queue|From
        QueueID          => 12,
        UserID           => 123,
    );

MailAccountGetAll()

returns an array of all mail account data

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

returns:

    @MailAccounts = (
        {
            ChangeTime       => '2021-03-15 11:05:52',
            Comment          => '',
            CreateTime       => '2021-03-15 08:06:06',
            DispatchingBy    => 'Queue',
            Host             => 'imap.host.com',
            ID               => 1,
            IMAPFolder       => 'INBOX',
            Outlook365Folder => 'INBOX',
            QueueID          => 2,
            CredentialID     => 2,
            Trusted          => 1,
            SSLVerify        => 0,
            SSLFingerprint   => '',
            SSLVerifyCN_Name => '',
            Type             => 'IMAPS',
            ValidID          => 1,
        },
        # ...
    );

MailAccountGet()

returns a hash of mail account data

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

(returns: ID, CredentialID, Host, Type, QueueID, Trusted, IMAPFolder, SSLVerify, SSLFingerprint, SSLVerifyCN_Name, Comment, DispatchingBy, ValidID)

MailAccountUpdate()

update a new mail account

    $MailAccount->MailAccountUpdate(
        ID               => 1,
        CredentialID     => 2,
        Host             => 'pop3.example.com',
        Type             => 'POP3',
        IMAPFolder       => 'Some Folder', # optional, only valid for IMAP-type accounts
        Outlook365Folder => 'Some Outlook365  Folder', # optional, only valid for Outlook365-type accounts
        ValidID          => 1,
        Trusted          => 0,
        SSLVerify        => 0,             # optional, available for secure type account
        SSLFingerprint   => '',            # optional, SSLFingerprint hash if SSLVerify is enabled
        SSLVerifyCN_Name => '',            # optional, SSLVerifyCN_Name if SSLVerify is enabled
        DispatchingBy    => 'Queue',       # Queue|From
        QueueID          => 12,
        UserID           => 123,
    );

MailAccountDelete()

deletes a mail account

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

MailAccountList()

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

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

returns:

    %List = (
        123 => 'imap.host.com (credential name)',
        ...
    );

MailAccountBackendList()

returns a list of usable backends

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

MailAccountFetch()

fetch emails by using backend

    my $Ok = $MailAccount->MailAccountFetch(
        CredentialID  => 1,
        Host          => 'pop3.example.com',
        Type          => 'POP3', # POP3,POP3s,IMAP,IMAPS
        Trusted       => 0,
        DispatchingBy => 'Queue', # Queue|From
        QueueID       => 12,
        UserID        => 123,
    );
Scroll to Top