How to access mail program on Windows server

M

Monty

I'm a novice programmer and have used this line of code to access the
mail program on my provider's server and it has worked fine:


$mailprog = '/usr/lib/sendmail -i -t';

# Open The Mail Program
open(MAIL,"|$mailprog");

print MAIL "To: ([email protected])";
print MAIL "From: Me";
etc etc

I'm now writing a script which will reside on a Windows server and will
need to send the contents of a form to an email address. How do I tell
the Perl in my CGI script where the Windows mail server is? It obviously
isn't at /usr/lib/sendmail . How do I code this section differently for
a Windows server than an Unix server?

Monty
 
G

Gunnar Hjalmarsson

Monty said:
I'm a novice programmer and have used this line of code to access
the mail program on my provider's server and it has worked fine:

$mailprog = '/usr/lib/sendmail -i -t';

# Open The Mail Program
open(MAIL,"|$mailprog");

print MAIL "To: ([email protected])";
print MAIL "From: Me";
etc etc

I'm now writing a script which will reside on a Windows server and
will need to send the contents of a form to an email address. How
do I tell the Perl in my CGI script where the Windows mail server
is? It obviously isn't at /usr/lib/sendmail . How do I code this
section differently for a Windows server than an Unix server?

If there is a command line MTA, similar to sendmail, installed, you
can just use the applicable path and possible flags. Otherwise (and
more likely) you'll need to make use of one of the many modules for
the purpose. My personal favorite is Mail::Sender, since it 'has it
all'. Often recommended here is MIME::Lite.

Btw, there are many form-to-mail programs available that you might
find useful. What kind of form is it? If it's a simple contact form,
you may want to explore the CPAN module CGI::ContactForm, which is
very easy to use. If you need more flexibility, you may prefer one of
the form-to-mail scripts at http://nms-cgi.sourceforge.net/scripts.shtml
 
A

A man

johndoe44 said:
I'm a novice programmer and have used this line of code to access the
mail program on my provider's server and it has worked fine:


$mailprog = '/usr/lib/sendmail -i -t';

# Open The Mail Program
open(MAIL,"|$mailprog");

print MAIL "To: ([email protected])";
print MAIL "From: Me";
etc etc

I'm now writing a script which will reside on a Windows server and will
need to send the contents of a form to an email address. How do I tell
the Perl in my CGI script where the Windows mail server is? It obviously
isn't at /usr/lib/sendmail . How do I code this section differently for
a Windows server than an Unix server?

I think it's just:
$mailprog = 'c:\program files\mailer\sendmail -i -t';

Add whatever command line args you need for the subject, to address,
and body. You can use the backslashes too.
 
G

Gunnar Hjalmarsson

A said:
I think it's just:
$mailprog = 'c:\program files\mailer\sendmail -i -t';

Is that a standard program on Windows servers? If not, how can you tell?
You can use the backslashes too.

Maybe, but what would the point be with that? They are not needed in
Perl programs, but it's easy to make mistakes if you use them.
 
P

pkent

Monty said:
I'm a novice programmer and have used this line of code to access the
mail program on my provider's server and it has worked fine:


$mailprog = '/usr/lib/sendmail -i -t';

# Open The Mail Program
open(MAIL,"|$mailprog");

print MAIL "To: ([email protected])";
print MAIL "From: Me";
etc etc

I'm now writing a script which will reside on a Windows server and will
need to send the contents of a form to an email address. How do I tell
the Perl in my CGI script where the Windows mail server is? It obviously
isn't at /usr/lib/sendmail . How do I code this section differently for
a Windows server than an Unix server?

If you want to not change your code much, I've heard of a drop-in
sendmail for windows...
http://w.google.com/search?q=sendmail for windows

There may be others.

OTOH search for Mail on search.cpan.org and there are perl modules to
help you send mail.

P
 
M

Monty

Sendmail for Windows works. It can be combined with an existing Windows
SMTP server to get the functionality I need. Hardly had to change my
script at all. Thanks so much for all of your help.

Monty
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,082
Members
48,773
Latest member
Kaybee

Latest Threads

Top