Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Mail on NT

by Anonymous Monk
on Apr 02, 2002 at 14:19 UTC ( #156004=perlquestion: print w/replies, xml ) Need Help??

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

Please advise how I can send email on a NT.
I have never been able to get this to work.
The script below works BUT wont work with my email part.
use LWP::Simple; use Mail::Mailer; $url = 'http://pathhere'; $content = get($url); print "This script checks if page has been changed.\n"; open(TMPFILE,"<previous_copy.html") or die; while (<TMPFILE>) { $prev_content .= $_; } close TMPFILE; if ($content eq $prev_content) { $mailer = Mail::Mailer->new(); $mailer->open({ from => 'fromemail@here', To => 'toemail@here', Subject => "test", }) or die "can not work: $!\n"; print "data\n"; $mailer->close(); } else { print "test\n"; } open(TMPFILE,">previous_copy.html") or die; print TMPFILE "$content"; close TMPFILE;

Error message:
C:\Perl\bin> This script checks if page has been changed. Died at C:/Perl/site/lib/Mail/ line 270.

Replies are listed 'Best First'.
(shockme) Re: Mail on NT
by shockme (Chaplain) on Apr 02, 2002 at 14:40 UTC
    I can't speak to Mail::Mailer, as I've never used it. Have you tried Mail::Sendmail? I've used it on several Windows platforms (from 9x to XP), and it's always worked well. It's independent of any "mailer" executable, such as sendmail, etc. The following code works for me (and is pretty much taken straight from the POD):
    use Mail::Sendmail; my %mail = ( To => "$emailAddys", From => "whatever\", Subject => "$subject", Message => "@body", ); $mail{smtp} = ''; sendmail(%mail) or die "\nDoh! $Mail::Sendmail::error\n";
    Update: Added example code per the following request.

    If things get any worse, I'll have to ask you to stop helping me.


      It now works. I appreciate all the replies.
      Again---Many Thanks!!
      Please show how sendmail would be used on an NT? I have used sendmail for Unix with no problems. Can you show me a script with the sendmail part on it using an NT??
Re: Mail on NT
by simon.proctor (Vicar) on Apr 02, 2002 at 14:59 UTC
    You cannot use Mail::Mailer in the default mode on NT as you have just discovered. You need to point the module at a mail server that can send mails on your behalf.
    eval{ my $mailer = new Mail::Mailer 'smtp', Server => $SERVER; # Send our options $mailer->open({ From => $SENDERALIAS . '<' . $SENDEREMAIL . '>', To => $TO . '<' . $EMAIL . '>', Subject => $SUBJECT }); print $mailer $message; }; if($@) { # Oops! print "$@\n"; }
    The above is an untested snippet based on the docs. I suggest you give that a try.
Re: Mail on NT
by strat (Canon) on Apr 02, 2002 at 15:30 UTC
    There was something like sendmail on NT, but recently it has be renamed to IndigoMail. I think you can use it from perl like sendmail (although I've never tried it yet).

    A tool I like to use is Blat which runs rather good under WinNT/2k/XP and also offers an easy way to send attachments. It's usage is similar to sendmail, only the parameters are slightly different.

    Best regards,
    perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"

Re: Mail on NT
by simonflk (Pilgrim) on Apr 02, 2002 at 14:49 UTC

    You need to add some debugging to find out where the script is dieing

    But since this script is running on NT, it is likely that you don't have mail/mailx/sendmail/etc executables on your system. In which case you might try using the "smtp" method in the Mail::Mailer docs.

    Finally, since you are sending html, you may want to use another module to send the mail. Perhaps MIME::Lite or MIME::Lite::HTML. Good luck


    -- simonflk

Re: Mail on NT
by dws (Chancellor) on Apr 02, 2002 at 17:40 UTC
    If your NT environemnt has Outlook installed, you can piggy-back off of Outlook to send email. I've done this a few times when the environment didn't provide an SMTP server.

    this node has some sample code, and a bit of searching user Super Search will turn up more examples.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-05-26 08:03 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (93 votes). Check out past polls.