[vhffs-dev] [svn] commit: r137 - /trunk/vhffs-listengine/src/listengine.pl

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Author: jd
Date: Mon Jan  9 01:36:27 2006
New Revision: 137

Log:
use Net::SMTP to send mails

Modified:
    trunk/vhffs-listengine/src/listengine.pl

Modified: trunk/vhffs-listengine/src/listengine.pl
==============================================================================
--- trunk/vhffs-listengine/src/listengine.pl (original)
+++ trunk/vhffs-listengine/src/listengine.pl Mon Jan  9 01:36:27 2006
@@ -20,7 +20,7 @@
 use Vhffs::Main;
 use Vhffs::Services::Mailing;
 use Vhffs::Listengine::Intl;
-
+use Net::SMTP;
 
 
 ###########################
@@ -71,6 +71,8 @@
     my $addrs = shift;
     my @tos;
     my $line;
+    my $adr;
+    my $smtp;
     my $header_pass = 0;
 
 
@@ -85,47 +87,20 @@
     else
     {
 	push @tos , $addrs;
-    }
-
-    my $proto = getprotobyname('tcp' );
-    socket(SOCK, AF_INET, SOCK_STREAM, $proto);
-    my $iaddr = gethostbyname( $SMTP_SERVER );
-    my $port = getservbyname('smtp' , 'tcp' );
-    my $sin = sockaddr_in( $port , $iaddr );
-    connect( SOCK, $sin );
-    my $err = '';
-
-    my @lines = split/\n/ , $mail->as_string;
-
-
-    recv SOCK, $err, 512, 0;
-    send SOCK, "HELO $DOMAIN\r\n", 0;
-    recv SOCK, $err, 512, 0;
-    send SOCK, "MAIL FROM: $ADMIN\r\n", 0;
-    recv SOCK, $err, 512, 0;
-    foreach (@tos){ 
-	send SOCK, "RCPT TO: $_\r\n", 0; recv SOCK, $err, 512, 0; 
-    }
-    send SOCK, "DATA\n", 0;
-    recv SOCK, $err, 512, 0;
-
-
-    pop( @lines );
-
-    foreach $line ( @lines )
-    {
-	next if( ( $header_pass == 0 ) && ( ! ( $line =~ /^[a-zA-Z0-9]+:\s.+$/) ) );
-	$header_pass = 1 if ( $line =~ /^[a-zA-Z0-9]+:\s.+$/);
-	send SOCK, "$line\n", 0;
-    }
-    send SOCK, ".\r\n", 0;
-    recv SOCK, $err, 512, 0;
-    send SOCK, "QUIT\r\n", 0;
-    recv SOCK, $err, 512, 0;
-    close SOCK;
-
-}
-
+   }
+
+	foreach $adr (@tos)
+	{
+		$smtp = Net::SMTP->new( $SMTP_SERVER,
+			Hello => $DOMAIN,
+                        Debug   => 1,
+		);
+
+		$smtp->mail( $mail->get('From') );
+		$smtp->to( $adr );
+		$smtp->data( $mail->as_string );
+	}
+}
 
 
 
@@ -821,7 +796,6 @@
 	    push( @mail , $line );
 	}
     }
-   # my @mail = <STDIN>;
     my $m = Mail::Internet->new( \@mail );
     return $m;
 }




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/