Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Sendmail query

by costas (Scribe)
on May 31, 2001 at 16:47 UTC ( #84532=perlquestion: print w/replies, xml ) Need Help??

costas has asked for the wisdom of the Perl Monks concerning the following question:

I am writing a cgi script which sends out mail

I am however working locally on IIS 4 running active perl I will later have to upload to a site running perl on apache

I have the following code in my mail script which doesnt work on IIS.

my $mailprog = "/usr/lib/sendmail";

What i want to know is will this work fine if i upload it to the Apache server.

I would also like to know what i should substitute this line of code for when writing for IIS.


Replies are listed 'Best First'.
Re: Sendmail query
by neophyte (Curate) on May 31, 2001 at 17:18 UTC
    A Super Search on Sendmail would have given you lots of relevant nodes. So here just a few hints:
    The path to sendmail varies from nix-box to nix-box, your apache server (apache is just the webserving software, not an OS) might have it in
    my $mailprog = "/usr/lib/sendmail"; or my $mailprog = "/usr/bin/sendmail";
    or somewhere else entirely. Your friendly sysadmin will be able to tell you.

    There is a sendmail for Win, but that is not necessarily installed on the box the IIS is running on. To be on the safe side you could use Net::SMTP, which runs on both platforms, but also is not guaranteed to be installed.


Re: Sendmail query
by THRAK (Monk) on May 31, 2001 at 16:58 UTC
    Maybe. If SendMail is in that location on that system and the code that uses it works. You may also want to look into Net::SMTP or Mail::Mailer. These should allow you to send mail from a WIN box if you have access to a SMTP server of some kind.

(boo) developing sendmail script on win32, production on *nix
by boo_radley (Parson) on May 31, 2001 at 17:24 UTC
    It might.
    Check with whomever administers that machine to verify the sendmail installation is probably the best starting point. That'll tell you if the path exists. Will your script work? who knows? :-)

    Also, you may wish to investigate the $^O variable :

    my $mailprog; if (lc($^O) eq "mswin32") #here is winland. {$mailprog = 'C:\sendmail\sendmail.exe'} # or whatever. I don't use sendmail on windows. else #here is *nixland {$mailprog = "/usr/lib/sendmail"}
    Update : Duh. Fixed error thanks to chromatic.
Re: Sendmail query
by mpolo (Chaplain) on May 31, 2001 at 17:34 UTC
    I'm not sure if you're writing from scratch or modifying one of those "bad" CGI scripts that are out there (or even one of those "good" scripts that use perl -T and But a couple points couldn't hurt.

    The command line flags you give to sendmail will be important for security. You will probably need to use -t and -i. The -t just tells sendmail to get the "To" and "Cc" information out of the headers of the mail you are sending. Unless you are root, you have to have a truthful "From", so that will be determined by the setup on the web server. The -i is very important. It tells sendmail that it should ignore any periods that are sitting on a line by themselves (this is the normal way to end an email in Unix) and wait until it receives the end of the input stream instead.

    The reasoning here is that if you are in a CGI environment, an evil user might put a period alone on a line inside of a comment section, for instance, and then the remaining characters are being thrown at the OS (and being possibly executed, depending on how things are set up). The -i will avoid this dangerous situation.

    According to the Module Reviews, the Mail::Sendmail module will work in both Windows and Unix, and may thus solve your dilemma.

      Is sendmail a perl module or is it a part of unix os
        sendmail is a BSD program that is widely (though not exclusively) used as a mail transport agent in the *nix world. The module Mail::Sendmail is misnamed, as it doesn't use sendmail on a Windows box. Some *nix machines will use qmail instead of sendmail, for instance.

        Update: I just read the Mail::Sendmail docs myself, and it sends out by SMTP if it can't find a local mailer. (The SMTP interface is not as advanced as in Net::SMTP.)

Re: Sendmail query
by BigJoe (Curate) on May 31, 2001 at 19:16 UTC
    I would use the Net::STMP module. This will allow your script to be run the same on an IIS server as it would on an Apache server. It is more cross platform friendly than hard coding programs into you scripts.


    Learn patience, you must.
    Young PerlMonk, craves Not these things.
    Use the source Luke.
Re: Sendmail query
by Beatnik (Parson) on May 31, 2001 at 21:52 UTC

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://84532]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (1)
As of 2023-06-02 05:59 GMT
Find Nodes?
    Voting Booth?

    No recent polls found