Kernel::System::EmailParser - parse and encode an email
A module to parse and encode an email.
create an object. Do not use it directly, instead use:
use Kernel::System::EmailParser; # as string (takes more memory!) my $ParserObject = Kernel::System::EmailParser->new( Email => $EmailString, Debug => 0, ); # as stand alone mode, without parsing emails my $ParserObject = Kernel::System::EmailParser->new( Mode => 'Standalone', Debug => 0, );
To get a email as a string back (plain email).
my $Email = $ParserObject->GetPlainEmail();
To get a header (e. g. Subject, To, ContentType, ...) of an email (mime is already done!).
my $To = $ParserObject->GetParam( WHAT => 'To' );
To get the senders email address back.
my $SenderEmail = $ParserObject->GetEmailAddress( Email => 'Juergen Weber <juergen.qeber@air.com>', );
to get the sender's RealName
.
my $Realname = $ParserObject->GetRealname( Email => 'Juergen Weber <juergen.qeber@air.com>', );
To get an array of email addresses of an To, Cc or Bcc line back.
my @Addresses = $ParserObject->SplitAddressLine( Line => 'Juergen Weber <juergen.qeber@air.com>, me@example.com, hans@example.com (Hans Huber)', );
This returns an array with ('Juergen Weber <juergen.qeber@air.com>', 'me@example.com', 'hans@example.com (Hans Huber)').
Returns the message body (or from the first attachment) "ContentType" header.
my $ContentType = $ParserObject->GetContentType(); (e. g. 'text/plain; charset="iso-8859-1"')
Returns the message body (or from the first attachment) "ContentDisposition" header.
my $ContentDisposition = $ParserObject->GetContentDisposition(); (e. g. 'Content-Disposition: attachment; filename="test-123"')
Returns the message body (or from the first attachment) "charset".
my $Charset = $ParserObject->GetCharset(); (e. g. iso-8859-1, utf-8, ...)
Returns the new message body (or from the first attachment) "ContentType" header (maybe the message is converted to utf-8).
my $ContentType = $ParserObject->GetReturnContentType();
(e. g. 'text/plain; charset="utf-8"')
Returns the charset of the new message body "Charset" (maybe the message is converted to utf-8).
my $Charset = $ParserObject->GetReturnCharset();
(e. g. 'text/plain; charset="utf-8"')
Returns the message body (or from the first attachment) from the email.
my $Body = $ParserObject->GetMessageBody();
Returns an array of the email attachments.
my @Attachments = $ParserObject->GetAttachments(); for my $Attachment (@Attachments) { print $Attachment->{Filename}; print $Attachment->{Charset}; print $Attachment->{MimeType}; print $Attachment->{ContentType}; print $Attachment->{Content}; # optional print $Attachment->{ContentID}; print $Attachment->{ContentAlternative}; print $Attachment->{ContentMixed}; }
To get an array of reference ids of the parsed email
my @References = $ParserObject->GetReferences();
This returns an array with ('fasfda@host.de', '4124.2313.1231@host.com').
This software is part of the OTRS project (https://otrs.org/).
This software comes with ABSOLUTELY NO WARRANTY. For details, see the enclosed file COPYING for license information (GPL). If you did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.