Gossamer Forum
Home : General : Perl Programming :

Mailing With NT

Quote Reply
Mailing With NT
If I was on a UNIX box I could open and send mail with this

Quote:
open (MAIL, "|/usr/lib/sendmail -t"); #path to the servers sendmail prog

but I am on a WinNT machine that uses SMTP address of mail.domainname.com is there away to use perl in this type of 'mail'?




------------------
Thanks in Advance

Daniel J.
http://www.blackrose.net
webmaster@blackrose.net
Quote Reply
Re: Mailing With NT In reply to
You can use the Mailer.pm that comes with Links. Just put it in the directory your perl program is in and do:

use Mailer;
my $mailer = new Mailer ( { smtp => 'mysmtpserver.com' } ) or die "Can't init: $Mailer::error";
$mailer->send ( { to => 'joe@joe.com', from => 'me@me.com', subject => 'Welcome!', msg => $msg } ) or die "Can't send: $Mailer::error";

Hope that helps,

Alex
Quote Reply
Re: Mailing With NT In reply to
 
Quote:
$mailer->send ( { to => 'joe@joe.com', from => 'me@me.com', subject => 'Welcome!', msg => $msg } )

Where would you define $msg ?



------------------
Thanks in Advance

Daniel J.
http://www.blackrose.net
webmaster@blackrose.net
Quote Reply
Re: Mailing With NT In reply to
This is portion of a script called database.pl

use NET::SMTP;
$smtp = Net::SMTP->new('mail.blackrose.net'); # connect to an SMTP server
$smtp->mail( 'SirDaniel\@blackrose.net' ); # use the sender's address here
$smtp->to $in{'Mail'}; # recipient's address
$smtp->data(); # Start the mail

# Send the header.
$smtp->datasend("To: $in{'Mail'}\n");
$smtp->datasend("From: SirDaniel\@blackrose.net\n");
$smtp->datasend("BCC: SirDaniel\@blackrose.net\n");
$smtp->datasend("Subject: Your Access Information\n");
$smtp->datasend("\n");

# # Send the body.
$smtp->datasend("Thank You for registering with us!!\n");
$smtp->datasend("Please save this message!\n");
$smtp->datasend("This information is REQUIRED to add/modify/delete your account info!\n");
$smtp->datasend("Please let others know of this free service!\n");
$smtp->datasend("Your ID, Password and E-Mail are:\n");
$smtp->datasend("Userid: $in{'userid'}\n");
$smtp->datasend("Pass: $in{'pw'}\n");
$smtp->datasend("E-Mail: $in{'Mail'}\n");
$smtp->datasend("\n");
$smtp->datasend("\n");
$smtp->datasend("\n");
$smtp->datasend("\n");
$smtp->datasend("Thank you for your time and good luck.\n");
$smtp->datasend("Sir Daniel\n");


$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP connection



When a user registers with us it takes his info and sends it to him (suppose to) so we can check the e-mail right away as well as send his user name and password to him so he does not forget it (hopefully).

I am on a Win NT Machine, SMTP.pm is in the same DIR as the database.pl script when I call it with , USE NET::SMTP, I receive a error that it
can not find NET/SMTP.pm

when I call it with, USE SMTP, it tells me it can not find SMTP.pm


------------------
Thanks in Advance

Daniel J.
http://www.blackrose.net
webmaster@blackrose.net


[This message has been edited by SirDaniel (edited January 20, 1999).]
Quote Reply
Re: Mailing With NT In reply to
TWO PARTS:
==========
Part One
Daniel,

The variable $msg is simply whatever you want to send to the user. You could easily set it to something incoming from the user:

$msg = $form_data{'message'};

Or with CGI.pm:

$msg = $query->param('message');

Or you could set it to a bunch of text:

$msg = qq~ This is a message to tell you
something very important, please read it
right now, or chicken feathers will grow
out your armpits.
~;

Hope this helps...

Part Two

The problem with putting modules in your program directories is simply that Perl doesn't ever look there for your module. It usually only looks in places that you have distiguished when setting up or installing PERL. Its easy enough to add information to this though. Since NT sometimes doesn't follow the shebang (#!) notation of UNIX for the first line, use this instead before you call your module:

use lib '/mypath/libdir/';
use SomeMod;

Replace the '/mypath/libdir' with the path where your module resides.


------------------
Fred Hirsch
Web Consultant & Programmer
Quote Reply
Re: Mailing With NT In reply to
  
Quote:
use lib '/mypath/libdir/';
use SomeMod;

the path to perl on the server or the path to the module in the script dir?

-----------
Modified
I just had to think about it for a few mins, it has to be the path to the perl lib.

-----------



------------------
Thanks in Advance

Daniel J.
www.blackrose.net
webmaster@blackrose.net


[This message has been edited by SirDaniel (edited January 21, 1999).]