Dylan Penhale wrote:
[posted to rush.general]
Just to follow up we ended up using the built in perl SMTP module
Net::SMTP module which is part of the "libnet" bundle.
Hi Dylan,
Sorry, I forgot to answer your original post.
Yes, it's probably wise to use the Perl SMTP module. eg:
---- snip
#!/usr/bin/perl -w
use strict;
use Net::SMTP;
my $mailfrom = 'you@(email surpressed)'; # from address
my $mailto = 'them@(email surpressed)'; # to address
my $relay = 'relay.here.com'; # your mail server hostname
my $smtp = Net::SMTP->new($relay);
if ( ! defined($smtp) )
{
# ERROR OCCURRED -- TRY AGAIN W/DEBUG ENABLED
$smtp = Net::SMTP->new($relay, Debug => 1);
if ( !defined($smtp) )
{ print "ERROR: Could not connect to $relay (see above)\n"; exit(1); }
}
# NOTE: Error checking an exercise to reader..
# for each of the following, check return code. eg. $errs |= $smtp->mail($mailto);
# Also, you probably should add Reply-To, Errors-To and Return-Path fields.
$smtp->mail($mailto);
$smtp->to($mailto);
$smtp->data();
$smtp->datasend("From: $mailfrom\n");
$smtp->datasend("To: $mailto\n");
$smtp->datasend("Subject: testing\n");
$smtp->datasend("\n");
$smtp->datasend("Line one");
$smtp->datasend("Line two");
$smtp->dataend();
$smtp->quit;
---- snip
I'm looking at the rushsendmail binary but I can't see how to issue
the whole command as one line without using an external file. This
will run on windows so I can't use the nix mail command.
102.42 now comes with 'rushsendmail' on all platforms,
but I don't recommend its use, as its interface and/or
behavior might change in the future.
However, for those curious, to use it from within perl
would be something like:
#!/usr/bin/perl -w
my $from = 'you@(email surpressed)'; # from address
my $to = 'them@(email surpressed)'; # to address
my $relay = 'mail.yourdomain.com'; # your mail server or relay hostname
$ENV{RUSH_DIR} ||= ( -d "c:/rush" ? "c:/rush" : "/usr/local/rush" );
open(FD, "|$ENV{RUSH_DIR}/etc/bin/rushsendmail -r -t -s$relay -f$from");
print FD <<"EOF";
From: $from
To: $to
Reply-To: $from
Errors-To: $from
Return-Path: $from
Subject: something to say
Line one
Line two
end of message
EOF
close(FD);
--
Greg Ercolano, erco@(email surpressed)
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)
Cel: (Tel# suppressed)
Fax: (Tel# suppressed)
|