File: SmtpForward.pl

package info (click to toggle)
getlive 0.59-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 184 kB
  • ctags: 19
  • sloc: perl: 1,051; makefile: 9
file content (27 lines) | stat: -rwxr-xr-x 490 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl -w

use strict;
use Net::SMTP;

my $Message;
my $Server  = "smtp.servername.com";
my $Address = "foo\@foobar.be";
my $From    = "foo\@foobar.be";

# Slurp the message and detect/remove the from.
while (<>) {
  if (m/^From:(.*)$/) {
    $From = $1;
    next;
  }
  $Message .= $_;
}


my $Mail = Net::SMTP->new($Server) || 
           die "Could not connect to SMTP server $Server : $!";

$Mail->mail($From);
$Mail->recipient($Address);
$Mail->data($Message);
$Mail->quit();