
#####
Email
#####


****
NAME
****


Kernel::System::Ticket::Article::Backend::Email - backend class for email based articles


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


This class provides functions to manipulate email based articles in the database.

Inherits from `Kernel::System::Ticket::Article::Backend::MIMEBase`, please have a look there for its base API,
and below for the additional functions this backend provides.


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


ArticleGetByMessageID()
=======================


Return article data by supplied message ID.


.. code-block:: perl

     my %Article = $ArticleBackendObject->ArticleGetByMessageID(
         MessageID     => '<13231231.1231231.32131231@example.com>',     # (required)
         DynamicFields => 1,                                             # (optional) To include the dynamic field values for this article on the return structure.
         RealNames     => 1,                                             # (optional) To include the From/To/Cc/Bcc fields with real names.
     );



ArticleSend()
=============


Send article via email and create article with attachments.


.. code-block:: perl

     my $ArticleID = $ArticleBackendObject->ArticleSend(
         TicketID             => 123,                              # (required)
         SenderTypeID         => 1,                                # (required)
                                                                   # or
         SenderType           => 'agent',                          # (required) agent|system|customer
         IsVisibleForCustomer => 1,                                # (required) Is article visible for customer?
         UserID               => 123,                              # (required)
 
         From        => 'Some Agent <email@example.com>',                       # required
         To          => 'Some Customer A <customer-a@example.com>',             # required if both Cc and Bcc are not present
         Cc          => 'Some Customer B <customer-b@example.com>',             # required if both To and Bcc are not present
         Bcc         => 'Some Customer C <customer-c@example.com>',             # required if both To and Cc are not present
         ReplyTo     => 'Some Customer B <customer-b@example.com>',             # not required, is possible to use 'Reply-To' instead
         Subject     => 'some short description',                               # required
         Body        => 'the message text',                                     # required
         InReplyTo   => '<asdasdasd.12@example.com>',                           # not required but useful
         References  => '<asdasdasd.1@example.com> <asdasdasd.12@example.com>', # not required but useful
         Charset     => 'iso-8859-15',
         MimeType    => 'text/plain',
         Loop        => 0, # 1|0 used for bulk emails
         Attachment => [
             {
                 Content     => $Content,
                 ContentType => $ContentType,
                 Filename    => 'lala.txt',
             },
             {
                 Content     => $Content,
                 ContentType => $ContentType,
                 Filename    => 'lala1.txt',
             },
         ],
         EmailSecurity => {
             Backend     => 'PGP',                       # PGP or SMIME
             Method      => 'Detached',                  # Optional Detached or Inline (defaults to Detached)
             SignKey     => '81877F5E',                  # Optional
             EncryptKeys => [ '81877F5E', '3b630c80' ],  # Optional
         }
         HistoryType    => 'OwnerUpdate',  # Move|AddNote|PriorityUpdate|WebRequestCustomer|...
         HistoryComment => 'Some free text!',
         NoAgentNotify  => 0,            # if you don't want to send agent notifications
     );
 
 
     my $ArticleID = $ArticleBackendObject->ArticleSend(                (Backwards compatibility)
         TicketID             => 123,                              # (required)
         SenderTypeID         => 1,                                # (required)
                                                                   # or
         SenderType           => 'agent',                          # (required) agent|system|customer
         IsVisibleForCustomer => 1,                                # (required) Is article visible for customer?
         UserID               => 123,                              # (required)
 
         From        => 'Some Agent <email@example.com>',                       # required
         To          => 'Some Customer A <customer-a@example.com>',             # required if both Cc and Bcc are not present
         Cc          => 'Some Customer B <customer-b@example.com>',             # required if both To and Bcc are not present
         Bcc         => 'Some Customer C <customer-c@example.com>',             # required if both To and Cc are not present
         ReplyTo     => 'Some Customer B <customer-b@example.com>',             # not required, is possible to use 'Reply-To' instead
         Subject     => 'some short description',                               # required
         Body        => 'the message text',                                     # required
         InReplyTo   => '<asdasdasd.12@example.com>',                           # not required but useful
         References  => '<asdasdasd.1@example.com> <asdasdasd.12@example.com>', # not required but useful
         Charset     => 'iso-8859-15',
         MimeType    => 'text/plain',
         Loop        => 0, # 1|0 used for bulk emails
         Attachment => [
             {
                 Content     => $Content,
                 ContentType => $ContentType,
                 Filename    => 'lala.txt',
             },
             {
                 Content     => $Content,
                 ContentType => $ContentType,
                 Filename    => 'lala1.txt',
             },
         ],
         Sign => {
             Type    => 'PGP',
             SubType => 'Inline|Detached',
             Key     => '81877F5E',
             Type    => 'SMIME',
             Key     => '3b630c80',
         },
         Crypt => {
             Type    => 'PGP',
             SubType => 'Inline|Detached',
             Key     => '81877F5E',
             Type    => 'SMIME',
             Key     => '3b630c80',
         },
         HistoryType    => 'OwnerUpdate',  # Move|AddNote|PriorityUpdate|WebRequestCustomer|...
         HistoryComment => 'Some free text!',
         NoAgentNotify  => 0,            # if you don't want to send agent notifications
     );


Events:
    ArticleSend


ArticleBounce()
===============


Bounce an article.


.. code-block:: perl

     my $Success = $ArticleBackendObject->ArticleBounce(
         From      => 'some@example.com',
         To        => 'webmaster@example.com',
         TicketID  => 123,
         ArticleID => 123,
         UserID    => 123,
     );


Events:
    ArticleBounce


SendAutoResponse()
==================


Send an auto response to a customer via email.


.. code-block:: perl

     my $ArticleID = $ArticleBackendObject->SendAutoResponse(
         TicketID         => 123,
         AutoResponseType => 'auto reply',
         OrigHeader       => {
             From    => 'some@example.com',
             Subject => 'For the message!',
         },
         UserID => 123,
     );


Events:
    ArticleAutoResponse


ArticleTransmissionStatus()
===========================


Get the transmission status for one article.


.. code-block:: perl

     my $TransmissionStatus = $ArticleBackendObject->ArticleTransmissionStatus(
         ArticleID => 123,   # required
     );


This returns something like:


.. code-block:: perl

     $TransmissionStatus = {
         ArticleID  => 123,
         MessageID  => 456,
         Message    => 'Descriptive message of last communication',  # only in case of failed status
         CreateTime => '2017-01-01 12:34:56',
         Status     => [Processing|Failed],
         Attempts   => 1,                                            # only in case of processing status
         DueTime    => '2017-01-02 12:34:56',                        # only in case of processing status
     }



ArticleCreateTransmissionError()
================================


Creates a Transmission Error entry for one article.


.. code-block:: perl

     my $Success = $ArticleBackendObject->ArticleCreateTransmissionError(
         ArticleID => 123,                   # Required
         MessageID => 456,                   # Optional
         Message   => '',                    # Optional
     );



ArticleGetTransmissionError()
=============================


Get the Transmission Error entry for a given article.


.. code-block:: perl

     my %TransmissionError = $ArticleBackendObject->ArticleGetTransmissionError(
         ArticleID => 123,   # Required
     );
 
     Returns:
     {
         ArticleID  => 123,
         MessageID  => 456,
         Message    => 'Descriptive message of last communication',
         CreateTime => '2017-01-01 01:02:03',
         Status     => 'Failed',
     }
     or undef in case of failure to retrieve a record from the database.



ArticleUpdateTransmissionError()
================================


Updates the Transmission Error.


.. code-block:: perl

     my $Result = $ArticleBackendObject->ArticleUpdateTransmissionError(
         ArticleID => 123,                           # Required
         MessageID => 456,                           # Optional
         Message   => 'Short descriptive message',   # Optional
     );


Returns 1 on Success, undef on failure.




