I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2009-08-14 12:04:36-07 by jaslong in response to 11248
Re: signing multipart alternative messages

Probably your best bet is to use MIME::Lite to construct the message, then express the entire message as a string. Once it is in string form, you can have Mail::DKIM create a signature for it. Concatenate the signature and the original message, then send it using something other than MIME::Lite.

If you really want to use MIME::Lite to send the message, perhaps something like this will work...

# $msg is the MIME::Lite object ### Prepare the Mail::DKIM object use Mail::DKIM::Signer; my $dkim = Mail::DKIM::Signer->new( Algorithm => "rsa-sha1", Method => "relaxed", Domain => "myhost.com", Selector => "mx1", KeyFile => "./private.key", ); # Mail::DKIM wants the message in the form it is transmitted, i.e. CR-LF line endings my $raw_data = $msg->as_string; $raw_data =~ s/\n/\015\012/gs; $dkim->PRINT($raw_data); $dkim->CLOSE; # Now create the signature my $sig = $dkim->signature; my ($header_name, $header_content) = split /:\s*/, $sig->as_string, 2; # Insert the signature at the beginning of the message (uses an undocumented API of MIME::Lite) unshift @{$msg->{Header}}, [ $header_name, $header_content ]; # Now send the message $msg->send();
Direct Responses: 11321 | 12718 | Write a response