File: SmtpAuthForward.pl

package info (click to toggle)
getlive 2.4%2Bcvs20120801-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 176 kB
  • ctags: 37
  • sloc: perl: 1,387; sh: 25; makefile: 6
file content (33 lines) | stat: -rwxr-xr-x 746 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
28
29
30
31
32
33
#!/usr/bin/perl -w

use strict;
use Net::SMTP_auth;

my $Debug    = 1;
my $Message;
my $Server   = "smtp.servername.com";
my $Address  = "foo\@foobar.be";
my $From     = "foo\@foobar.be";
my $AuthType = "login";
my $UserName = "MyUserName";	# For the smtp server.
my $Password = "MyPassword";	# For the smtp server.

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

my $Smtp = Net::SMTP_auth->new(Host=>$Server,Debug=>$Debug) || 
           die "Could not connect to SMTP server $Server : $!";

$Smtp->auth($AuthType,$UserName,$Password);
$Smtp->mail($From);
$Smtp->to($Address);
$Smtp->data();
$Smtp->datasend($Message);
$Smtp->dataend();
$Smtp->quit();