Add text/plain part to confirmation and notifiocation mails.

This commit is contained in:
Martin Kamerbeek 2010-11-10 15:04:17 +01:00
parent a15b6a0edb
commit 63b0a9edf1

View file

@ -331,14 +331,18 @@ sub sendSubscriptionConfirmation {
$var->{ actionIsSubscribe } = $action eq 'subscribe';
my $mail = WebGUI::Mail::Send->create( $self->session, {
to => $user->get('email'),
subject => $self->get('confirmationEmailSubject'),
to => $user->get('email'),
subject => $self->get('confirmationEmailSubject'),
contentType => 'multipart/alternative',
} );
my $templateId = $self->get('confirmationEmailTemplateId');
my $template = WebGUI::Asset::Template->new( $session, $templateId );
if ( $template ) {
$mail->addHtml( $template->process( $var ) );
my $content = $template->process( $var );
$mail->addHtml( $content );
$mail->addText( $self->transformToText( $content ) );
}
else {
$session->log->error( "Cannot instanciate confirmation email template with id [$templateId]" );
@ -362,14 +366,18 @@ sub sendNoMutationEmail {
$var->{ actionIsSubscribe } = $action eq 'subscribe';
my $mail = WebGUI::Mail::Send->create( $self->session, {
to => $user->get('email'),
subject => $self->get('noMutationEmailSubject'),
to => $user->get('email'),
subject => $self->get('noMutationEmailSubject'),
contentType => 'multipart/alternative',
} );
my $templateId = $self->get('noMutationEmailTemplateId');
my $template = WebGUI::Asset::Template->new( $session, $templateId );
if ( $template ) {
$mail->addHtml( $template->process( $var ) );
my $content = $template->process( $var );
$mail->addHtml( $content );
$mail->addText( $self->transformToText( $content ) );
}
else {
$session->log->error( "Cannot instanciate no mutation email template with id [$templateId]" );
@ -383,6 +391,18 @@ sub sendNoMutationEmail {
return;
}
sub transformToText {
my $self = shift;
my $html = shift;
my $text = $html;
#HTML::Entities::decode($text);
$text =~ s/<a.*?href=["'](.*?)['"].*?>(.+?)<\/a>/$2 ($1)/g;
$text = WebGUI::HTML::html2text($text);
return $text;
}
#----------------------------------------------------------------------------
sub logConfirmation {
my $self = shift;