I have been researching on this. i got a script when i try to run get an error connecting to server. This script i am just trying to get to work, but the main reason for this is to be able to insert it into another Perl script where i would like email to be sent automatically when the other part of the script does something!
[EMAIL PROTECTED] cgi-bin]# perl email.pl Content-type: text/plain
Couldn't connect to server at email.pl line 22. [EMAIL PROTECTED] cgi-bin]#
Regards,
Mel
---------------------email.pl
#!/usr/local/bin/perl
use Net::SMTP;
print "Content-type: text/plain", "\n\n";
my $DEBUG = 1;
if($DEBUG) { $| = 1; open(STDERR, ">&STDOUT"); }
# Set this variable to your smtp server name my $ServerName = "smtp.134.36.16.12";
# Create a new SMTP object $smtp = Net::SMTP->new($ServerName, Debug => 1);
# If you can't connect, don't proceed with the rest of the script die "Couldn't connect to server" unless $smtp;
# Initiate the mail transaction # Your "real" email address my $MailFrom = "[EMAIL PROTECTED]";
# Recipient's "real" email address my $MailTo = "[EMAIL PROTECTED]";
$smtp->mail( $MailFrom ); $smtp->to( $MailTo );
# Start the mail $smtp->data();
# Send the header # This address will appear in the message $smtp->datasend("To: [EMAIL PROTECTED]");
# So will this one $smtp->datasend("From: [EMAIL PROTECTED]"); $smtp->datasend("Subject: Test Message\n"); $smtp->datasend("\n");
# Send the body. $smtp->datasend("Hello World!\n\n");
# Send the termination string $smtp->dataend();
# Close the connection $smtp->quit();
_________________________________________________________________
On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile/mobilehotmail
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]