Perl and Windows server 2003

 
Post new topic   Reply to topic    Aprelium Forum Index -> Perl
View previous topic :: View next topic  
Author Message
mikem22
-


Joined: 26 Oct 2007
Posts: 13

PostPosted: Fri Oct 26, 2007 7:30 pm    Post subject: Perl and Windows server 2003 Reply with quote

Hi,

I am in the process of transferring one of our domains to Windows 2003 from a UNIX based server.

I have some CGI that I need to import, but having big problems sending email..


The current script is
Quote:

$recipient='me@there.com';
$sender = 'dummy12477@there.com' # to get around relaying issues
if (open(MAIL, "|$sendmail $sendmailFlags")) {
print MAIL "To: $pageOwner\n";
print MAIL "From: $sender\n";
print MAIL "Reply-To: $sender\n";
print MAIL "Subject: Quotation Request\n\n";
print MAIL "Request from: \n\n";
print MAIL "Contact: $contact \n";
print MAIL "eMail: $$FORM{'email'}; \n";

.....
Close MAIL;
};

I have installed Blat, QK SMTP server and Activestate 5.6 Perl and the scripts that dont use sendmail work fine. I searched through here and found some code for blat, but cant seem to get it to work..

Could anyone post a bit of code to;
Build the email
send it

Thanks in advance,

Mike
_________________
Mike Montgomery
Back to top View user's profile Send private message
aprelium-beta
-


Joined: 24 Jun 2004
Posts: 383

PostPosted: Sat Oct 27, 2007 9:25 am    Post subject: Re: Perl and Windows server 2003 Reply with quote

mikem22,

There is no Sendmail application by default on Windows. So you'll have to download Blat which is a sendmail compatible tool on Windows and configure your script to use it (instead of sendmail).

Blat is available from http://www.blat.net/ .
_________________
Beta Testing Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
mikem22
-


Joined: 26 Oct 2007
Posts: 13

PostPosted: Sat Oct 27, 2007 10:58 am    Post subject: Reply with quote

Hi, and thanks for looking ...


I have installed blat
I have also installed QK SMTP and this works fine in outlook express using localhost as SMTP server.

I used the following install for BLAT..

blat -install localhost from@mydomain.com 3 25 - username password
This was accepted with no errors.

3=Retries
25=Port
- Skip profiles

The CGI code uses the 'send mail' part of matts script and is as follows (just to test to get a 'sendmail' working)

Quote:

#!/C:/Perl/bin/perl

$fileout="someurl.html";
$SMTP_SERVER="Localhost";
$WIN_TEMPFILE = "c:/temp/formmail.$$";
$mailprog = 'c:/windows/system32/blat.exe'; #No way is this going in CGI-BIN!!

$recipient = 'mike@***.co.uk';
$sender='mike@***.co.uk';
$email='mike@***.co.uk';
$subject="Test\n\n";

open(MAIL,">$WIN_TEMPFILE");
local($BLAT_ARGS);
print MAIL "Website Quotation Request\n\n";
print MAIL "Type what you want have in the e-mail\n\n";
close (MAIL);

$WIN_TEMPFILE =~ s/\//\\/g;
$mailprog =~ s/\//\\/g;

$BLAT_ARGS = "$WIN_TEMPFILE -t $recipient -ss -serverSMTP localhost -penguin"; # Found this mod in Aprelium Forum.
$BLAT_ARGS .= "-f $email";
$BLAT_ARGS .= "-s \"$subject\" ";
$BLAT_ARGS .= "-q";

system "$mailprog $BLAT_ARGS";
unlink $WIN_TEMPFILE;

print "Location:$fileout\n\n";
exit;



The above generates the following output..

Win32 console utility to send mail via SMTP or post to usenet via NNTP by P.Mendes,M.Neal,G.Vollant,T.Charron,T.Musson,H.Pesonen,A.Donchey,C.Hyde http://www.blat.net syntax: Blat -to [optional switches (see below)] Blat -SaveSettings -f -server [-port ] [-try ] [-profile ] [-u ] [-pwd ] or Blat -install [[[]]] [-q] Blat -profile [-delete | ""] [profile1] [profileN] [-q] Blat -h Location:

No email is sent as it does not appear in QK's log..

I also tried without the mods to the BLAT_ARGS and it generates the same response.


The temp file is not deleted (unlink) so I guess the problem is in the syntax of the blat command line ??

Mike
_________________
Mike Montgomery
Back to top View user's profile Send private message
mikem22
-


Joined: 26 Oct 2007
Posts: 13

PostPosted: Sat Oct 27, 2007 11:26 am    Post subject: Reply with quote

Hi,

I have it working;

My syntax left out the spaces between e.g.
... -t $email"; should have been
... -t $email ";

What I did was put the arguments into 1 line of code..

Quote:

$BLAT_ARGS = "$WIN_TEMPFILE -t $recipient -f $email -s \"$subject\" ";


Mike
_________________
Mike Montgomery
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Tue Nov 13, 2007 3:12 pm    Post subject: Reply with quote

mikem22,

So it was this little missing space that caused all the trouble. :-) Glad to know that the problem is solved now.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Perl All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group