Gossamer Forum
Home : Products : DBMan : Installation :

Mailing

Quote Reply
Mailing
Hello there...

Has anybody tried this...?

These sort of scripts generally cause people to ask, ``is there a sendmail equivalent on Windows?'' If you need to send email from a Perl
script, there is no need to use an external program like sendmail. The libnet bundle includes Net::SMTP, a module that can be used to
send mail. Here is an example:

use Net::SMTP;

$smtp = Net::SMTP->new('here.com'); # connect to an SMTP server

$smtp->mail( 'user@here.com' ); # use the sender's address here

$smtp->to('user@there.com'); # recipient's address

$smtp->data(); # Start the mail

# Send the header.
#
$smtp->datasend("To: user@there.com\n");
$smtp->datasend("From: user@here.com\n");
$smtp->datasend("\n");

# Send the body.
#
$smtp->datasend("Hello, World!\n");

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

It seems like a pretty easy way of sending mail using Windows NT

Cheers
-JO
Quote Reply
Re: Mailing In reply to
Yes, although it's not as portable because SMTP module won't be installed everywhere (I'm always amazed at how uncommon these supposedly standard modules are).

You can try using my Mailer.pm module found in Links which has support for both SMTP (using Sockets) and Sendmail. Syntax would be:

my $mailer = new Mailer ( { smtp => 'someserver.com' } ) or die "Nope: $Mailer::error";
$mailer->send ( { to => 'a@a.com', from => 'b@b.com', subject => $subject, msg => $msg } ) or die "Nope: $Mailer::error";

just replace smtp => 'somserver.com' with sendmail => '/usr/lib/sendmail' to switch back and forth.

Hope this helps,

Alex
Quote Reply
Re: Mailing In reply to
Or you can also use Blat found at: http://gepasi.dbs.aber.ac.uk/softw/blat.html

The simplest way to use it that I've found is to pump data into it like you normally do with sendmail, ie:

<b>
open (MAIL, "|$blat_loc - -t $to -s $subject") &#0124; &#0124; die "Can't open $blat_loc!\n";
print MAIL "$body\n";
print MAIL "\x1a"; # NEEDED!!
close MAIL;
</b>