Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Log-Dispatch CPAN distribution.

Report information
The Basics
Id: 25255
Status: resolved
Priority: 0/
Queue: Log-Dispatch

People
Owner: Nobody in particular
Requestors: GTERMARS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Specify "Content-Type" for e-mail based logs
It'd be really nice if we could set the "Content-Type" for e-mail based logs. Admittedly the common case is "text/plain", but being able to set "text/html" and then use a callback to turn the text into HTML would be useful.
I've attached an untested patch here which adds support for setting the "Content-Type" for e-mail based logs. Unless explicitly provided, the Content-Type defaults to "text/plain", to preserve existing behaviour.
diff -r -u Log-Dispatch-2.16.orig/lib/Log/Dispatch/Email/MailSender.pm Log-Dispatch-2.16/lib/Log/Dispatch/Email/MailSender.pm --- Log-Dispatch-2.16.orig/lib/Log/Dispatch/Email/MailSender.pm 2006-12-19 11:32:13.000000000 -0800 +++ Log-Dispatch-2.16/lib/Log/Dispatch/Email/MailSender.pm 2007-03-02 13:34:23.503692852 -0800 @@ -50,6 +50,7 @@ to => ( join ',', @{ $self->{to} } ), subject => $self->{subject}, smtp => $self->{smtp}, + type => $self->{type}, } ); die "Error sending mail ($sender): $Mail::Sender::Error" @@ -78,6 +79,7 @@ min_level => 'emerg', to => [ qw( foo@bar.com bar@baz.org ) ], subject => 'Oh no!!!!!!!!!!!', + type => 'text/plain', smtp => 'mail.foo.bar' ); $email->log( message => 'Something bad is happening', level => 'emerg' ); @@ -133,6 +135,11 @@ set this in the mail it sends. We pass in 'LogDispatch@foo.bar' as the default. +=item * type ($) + +A string containing the "Content-Type" for the email message (defaults +to "text/plain"). + =item * buffered (0 or 1) This determines whether the object sends one email per message it is diff -r -u Log-Dispatch-2.16.orig/lib/Log/Dispatch/Email/MailSendmail.pm Log-Dispatch-2.16/lib/Log/Dispatch/Email/MailSendmail.pm --- Log-Dispatch-2.16.orig/lib/Log/Dispatch/Email/MailSendmail.pm 2006-12-19 11:32:13.000000000 -0800 +++ Log-Dispatch-2.16/lib/Log/Dispatch/Email/MailSendmail.pm 2007-03-02 13:36:24.501726002 -0800 @@ -22,6 +22,7 @@ my %mail = ( To => (join ',', @{ $self->{to} }), Subject => $self->{subject}, Message => $p{message}, + 'Content-Type' => $self->{type}, # Mail::Sendmail insists on having this parameter. From => $self->{from} || 'LogDispatch@foo.bar', ); @@ -48,6 +49,7 @@ ( name => 'email', min_level => 'emerg', to => [ qw( foo@bar.com bar@baz.org ) ], + type => 'text/plain', subject => 'Oh no!!!!!!!!!!!', ); $email->log( message => 'Something bad is happening', level => 'emerg' ); @@ -103,6 +105,11 @@ set this in the mail it sends. We pass in 'LogDispatch@foo.bar' as the default. +=item * type ($) + +A string containing the "Content-Type" for the email message (defaults +to "text/plain"). + =item * buffered (0 or 1) This determines whether the object sends one email per message it is diff -r -u Log-Dispatch-2.16.orig/lib/Log/Dispatch/Email/MailSend.pm Log-Dispatch-2.16/lib/Log/Dispatch/Email/MailSend.pm --- Log-Dispatch-2.16.orig/lib/Log/Dispatch/Email/MailSend.pm 2006-12-19 11:32:13.000000000 -0800 +++ Log-Dispatch-2.16/lib/Log/Dispatch/Email/MailSend.pm 2007-03-02 13:34:29.555994727 -0800 @@ -23,6 +23,7 @@ $msg->to( join ',', @{ $self->{to} } ); $msg->subject( $self->{subject} ); + $msg->set('Content-Type', $self->{type}); # Does this ever work for this module? $msg->set('From', $self->{from}) if $self->{from}; @@ -59,6 +60,7 @@ ( name => 'email', min_level => 'emerg', to => [ qw( foo@bar.com bar@baz.org ) ], + type => 'text/plain', subject => 'Oh no!!!!!!!!!!!', ); $email->log( message => 'Something bad is happening', level => 'emerg' ); @@ -110,6 +112,11 @@ A string containing an email address. This is optional and may not work with all mail sending methods. +=item * type ($) + +A string containing the "Content-Type" for the email message (defaults +to "text/plain"). + =item * buffered (0 or 1) This determines whether the object sends one email per message it is diff -r -u Log-Dispatch-2.16.orig/lib/Log/Dispatch/Email/MIMELite.pm Log-Dispatch-2.16/lib/Log/Dispatch/Email/MIMELite.pm --- Log-Dispatch-2.16.orig/lib/Log/Dispatch/Email/MIMELite.pm 2006-12-19 11:32:13.000000000 -0800 +++ Log-Dispatch-2.16/lib/Log/Dispatch/Email/MIMELite.pm 2007-03-02 13:34:34.288230753 -0800 @@ -21,7 +21,7 @@ my %mail = ( To => (join ',', @{ $self->{to} }), Subject => $self->{subject}, - Type => 'TEXT', + Type => $self->{type}, Data => $p{message}, ); @@ -49,6 +49,7 @@ ( name => 'email', min_level => 'emerg', to => [ qw( foo@bar.com bar@baz.org ) ], + type => 'text/plain', subject => 'Oh no!!!!!!!!!!!', ); $email->log( message => "Something bad is happening\n", level => 'emerg' ); @@ -100,6 +101,11 @@ A string containing an email address. This is optional and may not work with all mail sending methods. +=item * type ($) + +A string containing the "Content-Type" for the email message (defaults +to "text/plain"). + =item * buffered (0 or 1) This determines whether the object sends one email per message it is diff -r -u Log-Dispatch-2.16.orig/lib/Log/Dispatch/Email.pm Log-Dispatch-2.16/lib/Log/Dispatch/Email.pm --- Log-Dispatch-2.16.orig/lib/Log/Dispatch/Email.pm 2006-12-19 11:32:13.000000000 -0800 +++ Log-Dispatch-2.16/lib/Log/Dispatch/Email.pm 2007-03-02 13:34:19.683502304 -0800 @@ -27,6 +27,8 @@ optional => 1 }, buffered => { type => BOOLEAN, default => 1 }, + type => { type => SCALAR, + default => 'text/plain' }, } ); my $self = bless {}, $class; @@ -36,6 +38,7 @@ $self->{subject} = $p{subject} || "$0: log email"; $self->{to} = ref $p{to} ? $p{to} : [$p{to}]; $self->{from} = $p{from}; + $self->{type} = $p{type}; # Default to buffered for obvious reasons! $self->{buffered} = $p{buffered}; @@ -159,6 +162,11 @@ A string containing an email address. This is optional and may not work with all mail sending methods. +=item * type ($) + +A string containing the "Content-Type" for the email message (defaults +to "text/plain"). + =item * buffered (0 or 1) This determines whether the object sends one email per message it is