Re: Perl in Win32: How do I email form output?
by Mungbeans (Pilgrim) on May 24, 2001 at 18:52 UTC
|
You can get the packages from:
http://www.activestate.com/ppmpackages/
Bookmark this it can be hard to find.
Net::SMTP will do the job... this below provides a basic wrapper for some admin scripts I use. N.B. recipient list would be better as an array reference.
sub send_mail_via_smtp() {
### Parameters
my ($smtp_server,
$recipient_list,
$from,
$subject,
$body) = @_;
### Locals
my $to_line = '';
my $smtp = '';
my @recipients = '';
my $recipient = '';
### connect to SMTP server
$smtp = Net::SMTP->new(
$smtp_server,
#Debug => 1,
) or
die "send_mail_via_smtp(): Unable to connect to $smtp_server,
+$!, Stopped";
$smtp->mail($from);
@recipients = split(/,/, $recipient_list);
foreach $recipient (@recipients) {
$smtp->to($recipient);
$to_line = $recipient . ',' . $to_line
}
$to_line =~ s/,$//; # Strip off any trailing ,'s
### Start the actual mail
$smtp->data();
### Header
$smtp->datasend("To: $to_line\n");
$smtp->datasend("From: $from\n");
$smtp->datasend("Subject: $subject:\n");
$smtp->datasend("\n");
### Body
$smtp->datasend("$body\n");
### Send
$smtp->dataend();
$smtp->quit;
}
| [reply] [d/l] |
Re: Perl in Win32: How do I email form output?
by Beatnik (Parson) on May 24, 2001 at 18:59 UTC
|
Might as well mention the Net::SMTP URL, as well as NT Sendmail, the actual Sendmail app itself (which is also available on windows), as Blat. Mail::Sender can use several other Mail modules to send mail.
Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur. | [reply] |
|
My installation of perl doesn't even HAVE a mail directory in the lib directory!!!
| [reply] |
|
Assuming Perl is installed properly :
- Read PPM FAQ
- Read PPM FAQ
- Read PPM FAQ
- Read PPM FAQ
- Read PPM FAQ
- Log in as administrator
- Open a DOS box
- type : ppm and press enter
- type : install Net::SMTP and press enter
- follow steps described by PPM
Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur.
| [reply] [d/l] [select] |
|
Re: Perl in Win32: How do I email form output?
by larryk (Friar) on May 24, 2001 at 19:32 UTC
|
#!perl -w
use strict;
use Win32::OLE;
my $message = '';
while (<DATA>) { $message .= $_; }
my $mail = new Win32::OLE('Outlook.Application');
my $item = $mail->CreateItem(0);
$item->{'To'} = 'email@address.here';
$item->{'Subject'} = 'whatever you want';
$item->{'Body'} = $message;
if ( $item->Send() ) { print "email sent.\n" }
else { print "email not sent!\n" }
__DATA__
blah
blah
blah
| [reply] [d/l] |
Using ppm (was Re: Perl in Win32: How do I email form output?)
by mrmick (Curate) on May 24, 2001 at 18:42 UTC
|
If you have ActivePerl, then you can use ppm to get the
modules you need. If there are any problems with getting
through a firewall, you can download the packages from
Activestate's ftp site and install through ppm as well.
The documentation that comes with Activeperl is very clear.
Look in the html directory on your Perl installation.
(C:\perl\html\index.html, for example).
Mick | [reply] |
Re: Perl in Win32: How do I email form output?
by strfry() (Monk) on May 24, 2001 at 19:02 UTC
|
if you're looking for a program outside perl that sends e-mail, i'd suggest blat.
(and for a neat overview on using blat, do a search on it here, and maybe google too)
| [reply] |
|
Blat's an excellent program. I'm running ActivePerl on Win95 (sorry!), and needed to email form output. I used sendmail for Windows for some time, but it expired after thirty days and I switched to blat, which does the job just fine.
| [reply] |
Re: Perl in Win32: How do I email form output?
by AidanLee (Chaplain) on May 24, 2001 at 20:35 UTC
|
Honestly, I'm a big fan of Mail::Sender. It isn't as low-level as NET::SMTP and can be set up with a minimum of fuss, which is usually desirable in a scenario such as yours. | [reply] |
Re: Perl in Win32: How do I email form output?
by novitiate (Scribe) on May 24, 2001 at 20:19 UTC
|
ActiveState includes Graham Barr's libnet libarary, of which Net::SMTP, is a part. To see if you have it, just do:
perl -e "use Net:SMTP;"
bumbly, novitiate | [reply] [d/l] |
Re: Perl in Win32: How do I email form output?
by Anonymous Monk on May 24, 2001 at 22:11 UTC
|
You could also use the Mail::Sendmail module. It works equally
well in both Unix and Win32. | [reply] |
Re: Perl in Win32: How do I email form output?
by mexnix (Pilgrim) on May 24, 2001 at 22:17 UTC
|
If you have the ability to spend money on this gig, you might want to look at Sendmail by Indigo Star. I used this at an ISP that I worked at and it did the job. One licencse covers as many instances you want on a single server. Just put the .exe in your cgi-bin dir and it works. Has a small config file and a log file (for each instance). They even have perl examples on the site. Check it out.
Ryan Briones | [reply] |
Re: Perl in Win32: How do I email form output?
by murphya (Sexton) on May 25, 2001 at 18:15 UTC
|
In my experience Mail::SendMail is the way to go. Very easy to set, use and understand. Once you get it working once you can rip off the code for other applications and it is pretty much platform independent. | [reply] |