diff --git a/lib/WebGUI/Mailing/Email.pm b/lib/WebGUI/Mailing/Email.pm index f086fdc..fdb1eae 100644 --- a/lib/WebGUI/Mailing/Email.pm +++ b/lib/WebGUI/Mailing/Email.pm @@ -4,6 +4,7 @@ use strict; use warnings; use HTML::TreeBuilder; +use WebGUI::HTML; use base 'WebGUI::Crud'; @@ -143,6 +144,18 @@ sub absolutifyURIs { return $tb->as_HTML; } +sub transformToText { + my $self = shift; + my $html = shift; + + my $text = $html; + #HTML::Entities::decode($text); + $text =~ s/(.+?)<\/a>/$2 ($1)/g; + $text = WebGUI::HTML::html2text($text); + + return $text; +} + #---------------------------------------------------------------------------- sub send { my $self = shift; @@ -160,6 +173,7 @@ sub send { my $asset = $mailing->getAsset; my $content = $asset->processContentAsUser( $mailing->get('issueId'), $self->get('userId'), $configuration ); my $body = $self->absolutifyURIs( $content, $asset->getUrl ); + my $text = $self->transformToText( $body ); # Mail is a test mail but there is noone to send the result to if ( $self->get( 'isTest' ) && !$self->get('recipientEmail') ) { @@ -201,6 +215,7 @@ sub send { returnPath => "$messageId-bounce\@$domain", } ); $mail->addHtml( $body ); + $mail->addText( $text ); if ( $asset->can( 'getListHeaders' ) ) { my $listHeaders = $asset->getListHeaders( $self->user->get('email') );