Sending email in NT

Does anyone have a PERL script that works in NT? I have been using Comm.pl which does not work on an NT server.

I need to send the contents of a file (plain text) to an email address (fixed) when the user clicks a button.
LVL 1
KennyIT Application ExecutiveAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cadabraCommented:


goto http://www.activestate.com/packages/zips/

and get MailTools.zip

Look at send.html in the zipfile.

0
KennyIT Application ExecutiveAuthor Commented:
The documentation is very in adequate for me to understand the program. DO you know where I can get more documentation? Or maybe some samples?
Thanks
0
Kim RyanIT ConsultantCommented:
Taken from http://www.activestate.com/ActivePerl/docs/Perl-Win32/perlwin32faq4.html#How_do_I_send_email_from_Perl_fo

use Mail::Sender;
     
$sender = new Mail::Sender
{
 smtp => 'mail.yourdomain.com',
 from => 'your@address.com'
};
$sender->MailFile(
{
 to => 'some@address.com',
 subject => 'Here is the file',
 msg => "I'm sending you the list you wanted.",
 file => 'filename.txt'}
);

0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

KennyIT Application ExecutiveAuthor Commented:
This is the error message I get :
"
  Can't locate Mail/Sender.pm in @INC (@INC contains: c:/Perl/lib c:/Perl/site/lib .) at D:\Inetpub\Web\temp\abmarketing\cgi-bin\verify4.pl line 124.
BEGIN failed--compilation aborted at D:\Inetpub\Web\temp\abmarketing\cgi-bin\verify4.pl line 124.
"
Can you please tell me why? I have downloaded the "Sender.pm" and put it in my cgi-bin folder.


0
KennyIT Application ExecutiveAuthor Commented:
I have sorted out the above problem by getting the server administrator to copy the files to the relevant folders on the server.

However, although there are no error messages (I put in some checks - see below), the email is not reaching the recipient. I can use the server to send emails to the recipient if I FTP into the server and type the SMTP commands manually, therefore it is not a priviledge/restriction problem.

The code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
use Mail::Sender;
     
$sender = new Mail::Sender
{
 smtp => 'articulateonline.com',
 from => 'kenny@articulateonline.com'
};

 if      ($sender->MailFile(
      {
       to => 'kennyraj@hotmail.com',
       subject => 'Here is the file',
       msg => "I'm sending you the list you wanted.",
       file => '\cgi-bin\data\angeli.txt'}
      ))
 {}
 else
 {
 die(&HTML_Header("ERROR!!!"));
 }

0
KennyIT Application ExecutiveAuthor Commented:
I have sorted out the above problem by getting the server administrator to copy the files to the relevant folders on the server.

However, although there are no error messages (I put in some checks - see below), the email is not reaching the recipient. I can use the server to send emails to the recipient if I FTP into the server and type the SMTP commands manually, therefore it is not a priviledge/restriction problem.

The code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
use Mail::Sender;
     
$sender = new Mail::Sender
{
 smtp => 'articulateonline.com',
 from => 'kenny@articulateonline.com'
};

 if      ($sender->MailFile(
      {
       to => 'kennyraj@hotmail.com',
       subject => 'Here is the file',
       msg => "I'm sending you the list you wanted.",
       file => '\cgi-bin\data\angeli.txt'}
      ))
 {}
 else
 {
 die(&HTML_Header("ERROR!!!"));
 }

0
KennyIT Application ExecutiveAuthor Commented:
Sorry, I accidentally hit refresh :)
0
KennyIT Application ExecutiveAuthor Commented:
When I add the following code at the bottom, the program returns "ERROR: connect() failed" :

Addition to the bottom of earlier code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      if ( ($sender->{'error'}) < 0)
            {
            &HTML_Header("ERROR: $Mail::Sender::Error\n");
            }
      else
            {
            &HTML_Header("MESSAGE SENT OK");
            }
0
KennyIT Application ExecutiveAuthor Commented:
Adjusted points to 100
0
GnissmanCommented:
If you are running your script on NT you could use a tool similar to sendmail called "blat". You can download it from
http://www.interlog.com/~tcharron/blat.html

In Perl it can be used like this:
$result = 'blat.exe file.txt -s Subject -t me@you.com';

Note: Before you run it for the first time you have to set the parameters by calling it from DOS:

blat -install hostname user

Maybe this will work for you?
Gniss
0
cadabraCommented:
Hi zxr250,

You got me interested in your problem, so I did the following:

First I  tested the blat program, and found it unstable in several instances. Some of the tests I ran made blat crash. I did not try to fix the problem, rather I decided to use the sender.pm package.



I am using Activestate perl 522.

Here is a list of currently installed packages (ppm query):

Archive-Tar    [0.072  ] module for manipulation of tar archives.
Compress-Zlib  [1.03   ] Interface to zlib compression library
DBD-ODBC       [0.21   ] ODBC driver for the DBI module.
DBI            [1.13.1 ] Database independent interface for Perl
File-Tools     [2      ] This module is a wrapper for the various File moudles.
HTML-Parser    [2.23   ] SGML parser class
MIME-Base64    [2.11   ] Encoding and decoding of base64 strings
MailTools      [1.12   ] A set of perl modules related to mail applications
PPM            [1.1.1  ] Perl Package Manager: locate, install, upgrade
                         software packages.
Tk             [800.015] Tk - a Graphical User Interface Toolkit
URI            [1.04   ] Uniform Resource Identifiers (absolute and relative)
Win32-Internet [0.081  ] An object oriented interface to the Win32 Internet
                         Functions (WININET.DLL).
XML-Element    [0.10   ] Base element class for XML elements
XML-Parser     [2.27   ] A Perl module for parsing XML documents
libnet         [1.06   ] libnet is a collection of Perl modules which provides
                         a simple and consistent programming interface (API) to
                         the client side of various protocols used in the
                         internet community.
libwin32       [0.15.1 ] Win32-only extensions that provides a quick migration
                         path for people wanting to use the core support for
                         win32 in perl 5.004 and later.
libwww-perl    [5.45   ] Library for WWW access in Perl






After copying the file sender.pm to the appropriate directory:

C:\Perl522\site\lib\Mail\sender.pm

And fixing the following in the sender.pm -

change:

  use Base64;
  use MIME::QuotedPrint;

to:

  use MIME::Base64;
  use MIME::QuotedPrint;



I ran the code snippet bellow and it worked.
Note that the files in the attachments have double backslashes in the quotes.

In the code set values for the
variables:

$SMTPSERVER
$MAILFROM
$MAILTO
$MAILSUBJECT
$MAILMESSAGE
$ATTACHMENTS

then run the program.
If you have any problems, please post as much details as possible.


Cadabra.



code starts bellow (c:\temp\mailsender.pl):
===================================================================================


use Mail::Sender;
     
# set the following variables
$SMTPSERVER='yoursmtphost';
$MAILFROM='username@yoursmtphost';
$MAILTO='someone@somewhere';

$MAILSUBJECT='Here is the file';
$MAILMESSAGE="I'm sending you the list you wanted.";
$ATTACHMENTS='C:\\Perl522\\site\\lib\\Mail\\sender.pm,c:\\temp\\mailsender.pl';

# Code starts here
$sender = new Mail::Sender {smtp => $SMTPSERVER, from => $MAILFROM};
$sender->MailFile({to => $MAILTO, subject => $MAILSUBJECT,
              msg => $MAILMESSAGE,
             file => $ATTACHMENTS});

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cadabraCommented:
If you encounter problems, please test the above code directly with perl, (not through IIS), as this is the way I tried it. This will help us pinpoint the problems further.

Good luck,
Cadabra.
0
KennyIT Application ExecutiveAuthor Commented:
Yes! Thanks a million. It works now. I am only curious as to why I cannot receive the file (plain text) in MS Exchange (Inbox). It works fine on web emails (Hotmail), Outlook express, Eudora and MS Outlook.

I reckon it has something to do with the encoding method or something. I am cracking my head, trying to understand sender.pm well enough to solve this.

Thanks again.

0
cadabraCommented:
Have you solved the problem with Inbox yet ?
0
KennyIT Application ExecutiveAuthor Commented:
That is something I don't understand. I tried playing around with the setting in sender.pm, but I got no where.

Then, when my mail server gave some problems, I used a different smtp server and it worked fine. I still am not sure why that particular smtp server (NT) where I am storing the other HTML stuff (it is both a web and mail server) does not send out the email in a format that inboxx accepts, but the new one (Linux) does.
0
cadabraCommented:
One good place to find answers to problems like you encountered is at the support page at microsith:

http://www.microsith.com/support.php3

You are not alone ...   :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.