On Wed, Jun 1, 2011 at 01:05, Irfan Sayed <[email protected]> wrote:
[ snip ] > use HTML::Table; > use Mail::Sendmail; > > $table = new HTML::Table(2, 2); > print '<p>Start</p>'; > print $table->getTable; > print '<p>End</p>'; > > %mail = ( To => '[email protected]', > From => '[email protected]', > Message => "$table", > 'content-type' => 'text/html; charset="iso-8859-1"', > ); > > $mail{body} = $table; > > $mail{smtp} = 'ustu-zone.relay.abc.com'; > sendmail(%mail) or die $Mail::Sendmail::error; > print "OK. Log says:\n", $Mail::Sendmail::log; > > plz suggest > ObCodeReview: Turn on 'use strict' and 'use warnings', please. First, you should probably read the Mail::Sendmail FAQ on HTML email: <http://alma.ch/perl/Mail-Sendmail-FAQ.html#HTML> That will explain how to properly construct a multipart message that has both text and HTML parts. (Note that you're going to need to figure out how to represent your HTML table in text form.) Second, when you do the assignment to the 'body' key of the message hash, you're assigning the actual object. What you want to assign is the textual version of the table -- so that line should look like: $mail{body} = $table->getTable; (This is somewhat confusing, as HTML::Table overrides stringification -- so depending on the context you're evaluating it in, sometimes $table is going to turn into a string and sometimes it's going to remain an object unless you explicitly turn it into a string. That assignment is an example of the latter case.) j -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
