Hi Irfan, thanks for trying Perl. A few comments on your code.
On Wednesday 01 Jun 2011 08:05:30 Irfan Sayed wrote: > Hi All, > > > I wrote perl script to draw html tables and send that html tables in mail . > i used two modules 1: html::tables and 2: mail::sendmail > > but when i send mail , it never prints the actual table in the mail body > > following is the code snippet, > Please properly capitalise your English text - as case is case-sensitive there is no such module as "mail::sendmail". > use HTML::Table; > use Mail::Sendmail; > 1. Add "use strict;" and "use warnings;" to the beginning: http://perl-begin.org/tutorials/bad-elements/#no-strict-and-warnings > $table = new HTML::Table(2, 2); > print '<p>Start</p>'; > print $table->getTable; > print '<p>End</p>'; > 1. Declare the variable using "my" to make "use strict;" happy. [code] my $table [/code] 2. After that please avoid indirect-object notation: http://perl-begin.org/tutorials/bad-elements/#indirect-object-notation 3. Your indentation is bad. the "prints" should be aligned to the strating line - not in the middle. 4. You probably don't want to print this stuff to STODUT here. I don't know what it does actually. > %mail = ( To => '[email protected]', > From => '[email protected]', > Message => "$table", > 'content-type' => 'text/html; charset="iso-8859-1"', > ); 1. Declare %mail using "my". 2. 'content-type' is probably improperly captalised. 3. The single-qoutes handling in this are bad. 4. Please use UTF-8 instead of iso-8859-1. We are in 2011, not 1990. > > $mail{body} = $table; You can put that inside the %mail. > > $mail{smtp} = 'ustu-zone.relay.abc.com'; Likewise. > sendmail(%mail) or die $Mail::Sendmail::error; > print "OK. Log says:\n", $Mail::Sendmail::log; > > plz suggest From where did you learn Perl? This is very bad code. Please reply to list if it's a mailing list post - http://shlom.in/reply . Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ The Case for File Swapping - http://shlom.in/file-swap Trying to block Internet pornography is like climbing a waterfall and trying to stay dry. (-- one of Shlomi Fish's Internet Friends) Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
