Hi,
I have the original forrmail.pl from Matt Wright. It submits the information
from the html form by e-mail. I also want it to send a confirmation e-mail
to a user that filled out a form. I have the code for Unix, but not Windows.
Here's the difference. Under Unix version e-mail in the .pl file is sent
like this:
open (MAIL, "|$mailprogram -t");
print MAIL "To: $sender\n";
and so on...
close(MAIL);
Where in Windows all that e-mail info is being temporarly stored in buffer
and then win32::process (it has all the header information - to, from,
subject) is created to send that e-mail. In my code there is send_email
procedure and then send_confirmation. Here is what happens: confirmation
e-mail is being sent to both places. It looks like the temp file holding the
e-mail info is being changed faster than the first process (for send_mail)
can process the original temp file info. Here is the code for win32 process:
#'use' the process module.
use Win32::Process;
#theWin32:: module. Includes the Win32 error checking etc.
# see Win32:: section for included functions.
use Win32;
sub Error{
print Win32::FormatMessage( Win32::GetLastError() );
}
#Create the process object.
Win32::Process::Create($ProcessObj, $mailprog, "Blat
$tempdir\\tempfile -t $Config{'recipient'} -s \"$Config{'subject'}\" -f
$Config{'email'} -i \"$Config{'email'} ($Config{'realname'})\"", 0,
DETACHED_PROCESS, ".")|| die &Error;
#Set the process priority
#$ProcessObj->SetPriority(NORMAL_PRIORITY_CLASS)||die &Error;
#Wait for the process to end. NO timeout
$ProcessObj->Wait(0);
#open(MAIL,"|$mailprog $tempdir\\tempfile -t $Config{'recipient'} -s
\"$Config{'subject'}\" -i \"$Config{'email'} ($Config{'realname'})\" -f
$Config{'email'}") || die("Cannot execute $mailprog -- Check mailprog path
and permissions : $!");
#close(MAIL);
What should I do to make sure that it send first e-mail before it replaces
the info in the temp file with the new content.
Thanks,
Ksenia.