Re: Email::MIME issues
* Lyle [2009-02-16T10:27:01] > I guess the question really is, should Email::MIME take the single parts > headers, when only one part is added to the containing Email::MIME > object? Or should the single parts headers be lost, and the containing > Email::MIME objects headers be used. This is a bug in Stuff. The logic should be something like: if html xor text, start with that kind of part, with its attributes if html and text, start with multipart/alternative; attrs stay on parts if there are attachments, make multipart/mixed with parts [bodypart, att] Instead, the logic is much cruder, and is likely to produce incorrectly structured messages and, as you've found, trample attributes. My suggestion, if you don't want to really fix the code, is to not use Stuff. -- rjbs
Re: Email::MIME issues
Update:- I've improved the code snippet below to be more clear of what's happening. I guess the question really is, should Email::MIME take the single parts headers, when only one part is added to the containing Email::MIME object? Or should the single parts headers be lost, and the containing Email::MIME objects headers be used. #!/usr/bin/perl use strict; use warnings; use Email::Stuff; use Data::Dump qw(dump); ### This single part plain text MIME loses it's headers (charset, etc) my $ea = Email::Stuff->from('y[...]z.com')->subject('hello')->to('x[...]y.com') ->using( SMTP => '127.0.0.1' )->text_body( 'Hello mum', 'charset' => 'utf-8', 'content_transfer_encoding' => '8bit', ); #print dump($ea); print $ea->as_string, "\n\n"; ### This single part HTML MIME loses it's headers (charset, etc) my $ea2 = Email::Stuff->from('y[...]z.com')->subject('hello')->to('x[...]y.com') ->using( SMTP => '127.0.0.1' )->html_body( 'Hello mum', 'charset' => 'utf-8', 'content_transfer_encoding' => '8bit', ); #print dump($ea2); print $ea2->as_string, "\n\n"; ### This 2 part plain text and HTML MIME keeps the individual parts headers (charset, etc) my $ea3 = Email::Stuff->from('y[...]z.com')->subject('hello')->to('x[...]y.com') ->using( SMTP => '127.0.0.1' )->html_body( 'Hello mum', 'charset' => 'utf-8', 'content_transfer_encoding' => '8bit', )->text_body( 'Hello mum', 'charset' => 'utf-8', 'content_transfer_encoding' => '8bit', ); #print dump($ea3); print $ea3->as_string, "\n\n";
Email::MIME issues
Hi All, I've release a new email plugin for cgi-app based around Email::Stuff, CGI::Application::Plugin::Email. I've been going through Email::Stuff to try and understand it better. Looking at the RT there is a bug that's been sitting there for a year or so. http://rt.cpan.org/Public/Bug/Display.html?id=27320 I've gone through the code and started to write a patch... But it really does look like this could be an issue with Email::MIME rather than Email::Stuff. The problem is that if you create a new Email::MIME object without setting headers (it'll default to us-ascii), then add to it only one part with headers set (such as utf-8) the result is a single part message, but the headers defined by the part are lost. This isn't an issue if two parts are added (such as one text/plain, another html/text), as the headers for the individual parts are then maintained. The question is should I continue to patch Email::Stuff to replace the main Email::MIME objects headers with that of the parts if it is only and single part message. Or should the patch be for Email::MIME to do this? A code sample based on Email::Stuff to show this issue has been included below:- Lyle #!/usr/bin/perl use strict; use warnings; use Email::Stuff; use Data::Dump qw(dump); my $ea = Email::Stuff->from('y[...]z.com')->subject('hello')->to('x[...]y.com') ->using( SMTP => '127.0.0.1' )->text_body( 'Hello mum', 'charset' => 'utf-8', 'content_transfer_encoding' => '8bit', ); #print dump($ea); print $ea->as_string, "\n\n"; my $ea2 = Email::Stuff->from('y[...]z.com')->subject('hello')->to('x[...]y.com') ->using( SMTP => '127.0.0.1' )->html_body( 'Hello mum', 'charset' => 'utf-8', 'content_transfer_encoding' => '8bit', ); #print dump($ea2); print $ea2->as_string, "\n\n"; my $ea3 = Email::Stuff->from('y[...]z.com')->subject('hello')->to('x[...]y.com') ->using( SMTP => '127.0.0.1' )->html_body( 'Hello mum', 'charset' => 'utf-8', 'content_transfer_encoding' => '8bit', )->text_body( 'Hello mum', 'charset' => 'utf-8', 'content_transfer_encoding' => '8bit', ); #print dump($ea3); print $ea3->as_string, "\n\n";