in reply to Re^2: Send email on Windows Server
in thread Send email on Windows Server

You are writing a program and putting it on the server, right? You can include the source for Mail::Sendmail in your script...then you would leave out the 'use Mail::Sendmail' line, of course.

Also, not installing modules is stupid. What if you wrote a module with code that you wanted to reuse? Would they install that, or would you have to include the source in every script you wrote?

Replies are listed 'Best First'.
Re^4: Send email on Windows Server
by Anonymous Monk on Jan 19, 2007 at 02:06 UTC
    Thanks I would like to do that but I am in a restricted environment and they wont allow me to use the Mail::Sendmail source in my script. Any other way I can send mail on a Windows server in a Perl script??
      Please elaborate the restrictions you have. Do the admins revise your scripts and decide wether they are acceptable or not? Do they allow you to use any core perl module? Do they generally allow arbitrary/SMTP IP traffic originating from that box at all?

      You could use Socket;, connect to the remote MTA and speak SMTP yourself. It's not that hard for simple purposes. Here's a sample telnet session transcript:

      $ telnet localhost 25 ! Trying 127.0.0.1... ! Connected to localhost. ! Escape character is '^]'. < 220 qwurx ESMTP > HELO localhost < 250 qwurx > MAIL FROM: <shmem@qwurx> < 250 ok > RCPT TO: <shmem@qwurx> < 250 ok > DATA < 354 go ahead > From: shmem <shmem@qwurx> > To: myself <shmem@qwurx> > Content-Type: text/plain; charset=iso-8859-1 > Content-Transfer-Encoding: 8bit > Subject: Benevolent Advice > > get a clue, quick ;-) > . < 250 ok 1169199915 qp 22510 > QUIT < 221 qwurx ! Connection closed by foreign host.

      Lines beginning with "! " are diagnostics from telnet. Lines beginning with "> " are sent to the server, those with "< " are read from remote. See also RFC 2821.

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

      Hmm, any chance of tackling the problem from the other direction? Have your perl script output a file if anything needs mailing, and have a separate (non-perl) process that scans for the output file and emails it if it exists.

      Take a look at: Sending-Email-without-Client

      <update>I just tried out using the Pickup directory - that seems to work fine.</update>

      map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
      Tom Melly, pm@tomandlu.co.uk
      No, there is no way for you.