quietone has asked for the wisdom of the Perl Monks concerning the following question:

I am using blat.exe to send data from a form thru email and then displaying the data on another form. The data is displayed fine, however, it does not send an email. Anyone have any ideas??
sub display_sendemail { #use Win32::ODBC; $DSN="test"; $fromsender="someone\@somewhere.com"; $subject="Data"; $CustomerNumber = param("CustomerNumber"); $Name = param("Name"); $Address1 = param("Address1"); $City = param("City"); $State = param("State"); $ZipCode = param("ZipCode"); $Email = param("Email"); $server="server.name.net"; $recipient="someoneelse\@somewhereelse.com"; $message="$CustomerNumber.$Name.$Address1.$City.$State.$ZipCode.$Email +"; ## NO CONFIGURATION IS NECESSARY FROM HERE DOWN $blatpath="blat.exe "; $commandline = $blatpath; $commandline .= $message; $commandline .= "-q "; $commandline .= "-s \"$subject\" " if $subject; $commandline .= "-f $fromsender " if $fromsender; $commandline .= "-server $server " if $server; $commandline .= "-b $bccaddress " if $bccaddress; $db = new Win32::ODBC("DSN=$DSN;"); $commandline .= "-t \"$recipient\" "; system($commandline); #display results on screen print "Content-type: text/html\n\n"; print "<HTML>\n"; print "<HEAD>\n"; print "<TITLE>Account Information</TITLE>\n"; print "</HEAD>\n"; print "<BODY>\n"; print "<font face=arial>"; print "<b>Customer Number: </b>" . $CustomerNumber . "<br><br>\n"; print $Name . "<br>\n"; print $Address1 . "<br>\n"; print $City.","."&nbsp;". $State . "&nbsp;&nbsp;". $ZipCode . "<br><br +>\n"; print "<b>Email: </b>" . $Email . "\n"; print "<br>\n"; $db->Close(); print "</BODY>\n"; print "</HTML>\n"; }

Replies are listed 'Best First'.
Re: blat problems
by lachoy (Parson) on Apr 20, 2001 at 01:43 UTC

    When there are so many pure-Perl mail tools at your disposal, why use blat? Here's a sample using Mail::Sendmail, which is installable with PPM if you're using ActivePerl.

    use Mail::Sendmail; my $fromsender='someone@somewhere.com'; my $subject="Data"; my $CustomerNumber = param("CustomerNumber"); my $Name = param("Name"); my $Address1 = param("Address1"); my $City = param("City"); my $State = param("State"); my $ZipCode = param("ZipCode"); my $Email = param("Email"); my $server="server.name.net"; my $recipient='someoneelse@somewhereelse.com'; my $bccaddress = 'wheredidI@comefrom.com'; my $message="$CustomerNumber.$Name.$Address1.$City.$State.$ZipCode.$ +Email"; my %mail = ( Subject => $subject, From => $fromsender, To => $recipient, smtp => $server, Message => $message, Bcc => $bccaddress ); Mail::Sendmail::sendmail( %mail ); if ( $Mail::Sendmail::error ) { # ... display the error in $Mail::Sendmail::error # or however you wish to handle it } # everything else below this is for displaying HTML # and not relevant to this post...

    Two other things:

    Using single-quotes (') when creating strings means you don't have to escape the '@' character as you had in your original code.

    I used 'my' to initialize all your variables so it would run under use strict;, which is highly recommended. It will save you more time than you know. It pointed out, for instance, that $bccaddress was never initialized.

    Chris
    M-x auto-bs-mode

Re: blat problems
by eejack (Hermit) on Apr 20, 2001 at 05:17 UTC