home *** CD-ROM | disk | FTP | other *** search
- Sends email by using the SMTP Server
- Viotix Incoporated
-
- sub send_mail{
- my ($from, $to, $subject, $body) = @_;
-
- use Net::SMTP;
-
- # set to 1 to enable debug mode
- my $debug = 0;
-
- # get the recipients for smtp to identify
- my $smtp_from = $from;
- my $smtp_to = $to;
-
- # build the mail message
- my $mail_message = <<__END_OF_MAIL__;
- To: $to
- From: $from
- Subject: $subject
-
- $body
-
- __END_OF_MAIL__
-
- # Set this parameter if you don't have a valid Net/Config.pm entry for SMTP host
- # and uncomment it in the Net::SMTP->new call
- # my $smtp_server = 'my.mailhost.com';
-
- # init the server
- my $smtp = Net::SMTP->new(
- # $smtp_server,
- Timeout => 60,
- Debug => $debug,
- );
-
- # I'm $smtp_from
- $smtp->mail($smtp_from) or warn ("Failed to specify a sender [$smtp_from]\n");
-
- # Please Send the email to $smtp_to
- $smtp->to($smtp_to) or warn ("Failed to specify a recipient [$smtp_to]\n");
-
- # Please send this data
- $smtp->data([$mail_message]) or warn ("Failed to send a message\n");
-
- # I'm over
- $smtp->quit or warn ("Failed to quit\n");
-
- } # end of sub send_mail
-
-
-
- # don't remove
-
- 1;
-
-