Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

(jcwren) Re: Sending mail on NT

by jcwren (Prior)
on Jul 20, 2000 at 01:12 UTC ( #23303=note: print w/replies, xml ) Need Help??

in reply to Sending mail on NT

Net::SMTP works fine on my NT servers. You can check if they're installed on your server by doing ths following:
perl -e 'use Net::SMTP;'
If you get an error to the effect that it can't find them, then they're indeed not installed. However, that shouldn't stop you from installing them. Since most NT systems really aren't setup for security (like Linux boxes), you could just hop on over to CPAN and fetch them. I think the Net::SMTP is a pure Perl module, so you shouldn't need a compiler to install it. You may have to grab a copy of make, nmake or dmake from somwhere however.

Net::SMTP is not reliant on any underlying O/S programs, such as sendmail. It basically uses sockets to connect to the mail server. Which, incidently, could be your problem. You'll need the DNS entry or IP address of a mail server that supports SMTP, or it won't be able to send mail. If your business is running Exchange, it can easily be configured to support SMTP. A couple of settings in the admin program will set it up.

Here's even some sample code to talk to the SMTP server (I've changed the address to, you'll need to use yours)
#!/usr/local/bin/perl -w use strict; use Net::SMTP; my $globalMailServer = ""; { sendmail ('', # put real e-mail address + here 'My Name Goes Here', # put your real name here '', # put dest e-mail address + here 'Leon The Peon', # put dest name here 'Your fired!', # subject 'This is some message text'); # message } sub sendmail { @_ == 6 or die "Improper number of arguments"; my ($fromemail, $fromname, $toemail, $toname, $subject, $message) += @_; my $smtp = 0; $smtp = Net::SMTP->new($globalMailServer) or die "Can't connect to + mail server named '$globalMailServer'\n"; $smtp->mail ($fromemail); $smtp->to ($toemail); $smtp->data (); $smtp->datasend ("To: $toname\n"); $smtp->datasend ("From: $fromname\n"); $smtp->datasend ("Subject: $subject\n"); $smtp->datasend ("\n"); $smtp->datasend ($message); $smtp->dataend (); $smtp->quit; }
This subroutine is a direct extract from some code around here. I also just tested this code, so it should work for you, if you fix the mail server address.


Update: I just noticed where you said you can't install modules. Is that because you're not permitted to, or because you don't believe you can since you're not a system administrator? If it's a case of the latter, CPAN modules can be installed into a users directory, as opposed to the system directories. If it's because they won't permit you, you can always hack the code out of Net::SMTP and include it in your script, or treat it as a module (doable, but not the wisest way.)

e-mail jcwren

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://23303]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2018-03-23 17:21 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (295 votes). Check out past polls.