blat email setup.

previuosly i run my script under unic. noe i try under NT. i've got a problem when i try to run my email program.
below is part of the coding.

#!c:\perl\bin\perl.exe

$mailprog = "c:\blat\blat.exe";    
&parse_form;

$message = "" ;
$found_err = "" ;

$errmsg = "<p>invalid email address!!</p>\n" ;

if ($FORM{'Email'} !~ /.+\@.+\..+/)
{
      $message = $message.$errmsg ;
      $found_err = 1 ; }

if ($found_err) {
      &PrintError; }


else
   {  

$recip = "rizam\@if.com.my";
$cc_recip = "sales\@if.com.my";
open (MAIL, "|$mailprog") || die print "Cannot open mailprog";
print MAIL "To: $recip\n\n";
print MAIL "cc: $cc_recip\n";
print MAIL "From: $FORM{'Email'}\n";
print MAIL "Subject: web order\n";
print MAIL "Form Posted From: $ENV{'HTTP_REFERER'}\n";
print MAIL "\n\n";
print MAIL "\n" ;
print MAIL "Username         : ".$FORM{'usr'}."\n";
print MAIL "Password         : ".$FORM{'passw'}."\n";
if ($FORM{'deladdress'})
{
print MAIL "Delivery Address : ".$FORM{'deladdress'}."\n";
}
print MAIL "*******************************************************************\n";

print MAIL "\n";

if ($FORM{'Item0'})
{
print MAIL "hi there \n";
print MAIL "Item Number     : ".$FORM{'Item0'}."\n";
print MAIL "Re. Number      : ".$FORM{'ID0'}."\n";
print MAIL "Description     : ".$FORM{'Description0'}."\n";
print MAIL "Quantity        : ".$FORM{'Qty0'}."\n";
print MAIL "Price Each      : ".$FORM{'PriceEach0'}."\n";
print MAIL "Sub Total       : ".$FORM{'TotalPrice0'}."\n";
print MAIL "\n";
}
print MAIL ".\n" ;
print MAIL "\n\n";
close (MAIL);
print "Location: http://chukai.virtualave.net/chukai_supplies.htm\n";
print "Content-Type: text/html\n\n";
exit;
}
and parse_form code after this.

this program runs smoothly under unix. when i try under NT(using blat), error appears .
the error is:
Cannot open mailprog.

someone please help me
kudakAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jmcgOwnerCommented:
Maybe you need to double up the backslashes in your string?

  $mailprog = "c:\\blat\\blat.exe";
0
Kim RyanIT ConsultantCommented:
Windows will not understand your first line, #! only has meaning on Unix. Try running your program from commnad line with:  perl yourprog.pl

Also for sending mail from windows check: http://www.activestate.com/ActivePerl/docs/Perl-Win32/perlwin32faq4.html#How_do_I_send_email_from_Perl_fo 

 
0
kudakAuthor Commented:
teraplane, i've tried to change it(first line) but the script could not run. i ask the server administrator and he told me to use the one that i write.

jmcq, i also have tried yours. the script seems to run smoothly without any errors, but the problem is, the script cannot send that email to the address that i've specified, in this case rizam\@if.com.my and sales\@if.com.my
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

jmcgOwnerCommented:
So do I get partial credit for spotting the problem causing your error message?

This line has an extra \n in it. That's terminating your header early.

print MAIL "To: $recip\n\n";

But I suspect you can't expect Blat to parse your message content to extract the header. These two example scripts for Blat, found through the URL given by teraplane, both write the content of the message to a file and specify the header information on the command line. In this respect, Blat appears to not be a plug-for-plug compatible replacement for Sendmail.

http://gepasi.dbs.aber.ac.uk/softw/mail_blat.txt
http://gepasi.dbs.aber.ac.uk/softw/blatpl.txt
0
kudakAuthor Commented:
ok, make it as simple as possible.
i've changed my coding to look simpler. below is my coding.

#!c:\perl\bin\perl.exe

$mailprog = "c:\\blat\\blat.exe";    
&parse_form;
$recip = $FORM{'Email'};

open (MAIL, "|$mailprog") || die print "cannot open mailprog";
print MAIL "To: $recip\n";
print MAIL "Subject: Terima Kasih\n";
print MAIL "\n\n";
close (MAIL);
print "<html><title>thanks</title><body><h>hi</h></body></html>\n\n";


sub parse_form {

   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
   if (length($buffer) < 5) {
         $buffer = $ENV{QUERY_STRING};
    }
 
  @pairs = split(/&/, $buffer);
   foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);

      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

      $FORM{$name} = $value;
   }
}

when i run this program(key in email address from browser), it'll prompt me to download the file(email2.pl). i suspect that i can not use parse_form function
0
jmcgOwnerCommented:
A. You've forgotten to do to email2.pl whatever you did to the first script to make it so the httpd executes it rather than downloads it.

B. You did not look at the usage examples I pointed you to. If you had, you would not still be opening a pipe to blat.exe.
0
khacharnCommented:
hi kudak
I belive that you have the email adresses in the script you want to send that mail to..ok
fine
now there is a very simple answer to you problem..
Get the mails in you program(mail.pl) from the form(oranywhere)..DONE
Now in your mail.pl
Just do this
**************************************
system("start blat.exe filename -t <to address> -c <ccemailaddys> -b <bccemailaddys>");
***************************************
This will do all the sending.
of course you can have error messages if blat does not work..(but in my case it works just fine..)

Hope this help
ASK more if needed
Regards
Nitin
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kudakAuthor Commented:
i've tried yours khacharn but still i could not run it. well, if you don't mind, could you post your script to me. my email address is kudak@hotmail.com.

actually i just rent a server(remote server). i really do not know how blat is running. but i have one script i got from the internet.
part of the coding is:

exec("c:/windows/blat c:/zbs/temp/mailfile.txt -t i:/web/docs/ \n\n");
then,
open(MAIL, ">c:/WebSite/temp/mailfile.txt");

can someone tell me what's this coding means??
in my case i think i should code like
exec(c:\blat\blat.exe c:\bla\bla\bls -t xxx \n\n");
what's i:/web/dosc/ (xxx) for?? should'nt it be the same for c:/zbs/temp/mailfile.txt -t and c:/WebSite/temp/mailfile.txt??

thanks.
0
khacharnCommented:
Kudak
Well I have been using Visaul Basic with Blat
So possibly the code won't be of much help..
I will explain you the whole concept..
I think that you have the email address yoou want to mail to..RIGHT ?
Now you need a tool to mail to thet Email..Right ?
USE BLAT in your perl script..HOW ???
here it is..
befor using blat you should know its Functionlaity..
i give you a small example..

***************************************
<pathofblat.exe> textfile.txt(contians the message you want to send) -t <emailaddress> -b  <emailaddresses>
****************************************

Now in your perlscript
use it like this
***************************************
system("start pathofblat.exe textfile.txt -t <emailaddress> -b <emailaddress>
***************************************
Regards
Nitin
If you still don't get it tell me your problem very specifically
Ok
Nitin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.