in reply to Sending mail with a callback to track progress
#!/usr/bin/perl -wd # use MIME::Lite; ### Create a new multipart message: $msg = MIME::Lite->new( From => 'foo@bar.com', To => 'bar@foo.com', Subject => 'A message with 2 parts...', Type => 'multipart/mixed' ); $msg->attach( Type => 'TEXT', Data => "Here's the file you wanted" ); $msg->attach( Type => 'text/plain', Path => 'baz.txt', Filename => 'baz.txt', Disposition => 'attachment' ); $msg->send;
is pretty efficient. The file is not processed until the send method is called and then it's pushed across the sendmail pipe (or whatever mailer your using) in 2K chunks
update: looking at the MIME::Lite code, it would be trivial to implement a callback feature. You need to modify the build method to not reject the key and the print_simple_body method to utilize the callback. Then you could do something like this:
$msg->attach( Type => 'text/plain', Path => 'foo.txt', Filename => 'foo.txt', Disposition => 'attachment', Callback => \&hashit, ); $msg->send; sub hashit { print STDERR "#"; }
|
|---|