How to access mail program on Windows server

Discussion in 'Perl Misc' started by Monty, Jan 7, 2004.

  1. Monty

    Monty Guest

    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: ()";
    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
    Monty, Jan 7, 2004
    #1
    1. Advertising

  2. Monty wrote:
    > 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: ()";
    > 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

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Jan 7, 2004
    #2
    1. Advertising

  3. Monty

    A man Guest

    In article <RZNKb.720$>, johndoe44
    @hotmail.com spoke thusly...
    >
    > 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: ()";
    > 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.


    --
    Say no to fixed width tables. They look terrible in all browsers.
    A man, Jan 7, 2004
    #3
  4. A man wrote:
    > In article <RZNKb.720$>,
    > johndoe44 @hotmail.com spoke thusly...
    >> 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';


    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.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Jan 7, 2004
    #4
  5. Monty

    pkent Guest

    In article <RZNKb.720$>,
    Monty <> wrote:

    > 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: ()";
    > 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

    --
    pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
    Remove the tea to reply
    pkent, Jan 7, 2004
    #5
  6. Monty

    Monty Guest

    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


    pkent wrote:

    > In article <RZNKb.720$>,
    > Monty <> wrote:
    >
    >
    >>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: ()";
    >> 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
    >
    Monty, Jan 8, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Leon
    Replies:
    5
    Views:
    786
  2. Tim
    Replies:
    12
    Views:
    1,265
    kchayka
    Jul 15, 2005
  3. kj7ny
    Replies:
    3
    Views:
    989
    fynali
    Jul 10, 2007
  4. radgey gadgey hl
    Replies:
    0
    Views:
    704
    radgey gadgey hl
    Nov 25, 2007
  5. Replies:
    0
    Views:
    115
Loading...

Share This Page