QuoteVerbindung zum SMTP-Server unmöglich.
Server returned error after sending EHLO.
QuoteWenn der Sender sich beim Server nicht wie oben gezeigt mit HELO, sondern mit EHLO (Extended HELO) meldet, teilt der Server ihm im Gegenzug mit, welche Erweiterungen des Protokolls er unterstützt.
QuoteCant locate object method "new" via package "IO::Socket::INET" (perhaps you for got to load "IO::Socket::INET"?= at line 8
Quoteperl makefile.pl
dmake
dmake install
use IO::Socket::INET;
1 2
$server = new IO::Socket::INET Listen => 1, LocalPort => 25; $server = IO::Socket::INET->new(Listen => 1, LocalPort => 25);
2013-05-21T10:31:15 GustlHab folgende Varianten getestet:
Code (perl): (dl )1 2$server = new IO::Socket::INET Listen => 1, LocalPort => 25; $server = IO::Socket::INET->new(Listen => 1, LocalPort => 25);
http://search.cpan.org/perldoc?indirectThe indirect syntax is now considered harmful, since its parsing has many quirks and its use is error prone
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
#!/usr/bin/perl use warnings; use strict; use IO::Socket::INET; use Net::Server::Mail::SMTP; #our $host = $ARGV[0] || "157.163.168.131" ; $| = 1; my @local_domains = qw(example.com example.org); my $server = IO::Socket::INET->new(Listen => 1, LocalPort => 25); print "Waiting for incoming SMTP connections\n"; my $conn; while($conn = $server->accept) { my $smtp = Net::Server::Mail::SMTP->new(socket => $conn); $smtp->set_callback(RCPT => \&validate_recipient); $smtp->set_callback(DATA => \&queue_message); $smtp->process() or die $!; $conn->close(); } sub validate_recipient { my($session, $recipient) = @_; my $domain; if($recipient =~ /@(.*)>\s*$/) { $domain = $1; } if(not defined $domain) { return(0, 513, 'Syntax error.'); } elsif(not(grep $domain eq $_, @local_domains)) { return(0, 554, "$recipient: Recipient address rejected: Relay access denied"); } return(1); } sub queue_message { my($session, $data) = @_; my $sender = $session->get_sender(); my @recipients = $session->get_recipients(); return(0, 554, 'Error: no valid recipients') unless(@recipients); my $msgid = add_queue($sender, \@recipients, $data) or return(0); return(1, 250, "message queued $msgid"); }
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
#!/usr/bin/perl -w use strict; use MIME::Lite; # EMail verfassen my $mailfrom = 'name@email.de'; my $mailto = 'name@email.de'; my $subject = "TEST_SUBJECT"; my $mailtext ="TEST"; #E-Mail versenden: my $msg = MIME::Lite->new( From => $mailfrom, To => $mailto, Subject => $subject, Type => "multipart/related" ); $msg->attach( Type => "text/html", Data => $mailtext, ); $msg->send("smtp", "157.163.168.131"); #or die ... #mail.dc4ca.siemens.de print "Email von $mailfrom an $mailto gesendet!";
QuoteSMTP Failed to connect to mail server: Bad file descriptor at line 25
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
#!/usr/bin/perl use Socket; use warnings; use strict; my $port = 25; my $sockaddr = 'S n a4 x8'; my $authcount=0; my ($name, $aliases, $proto) = getprotobyname('tcp'); print "Port = $port\n"; my $thisaddr = gethostbyname('157.163.168.131'); my $this = pack($sockaddr, AF_INET, $port, $thisaddr); socket(S, AF_INET, SOCK_STREAM, $proto); bind(S,$this) || die "bind: $!"; listen(S,5) || die "connect: $!"; select(S); $| = 1; select(STDOUT); my $pid; for(;;) { print "Listening for connection....\n"; my $mail_content = ""; my $bool_data = 0; my $addr; ($addr = accept(NS,S)) || die $!; send(NS,"220 okey-dokey\r\n",0); my ($af,$port,$inetaddr) = unpack($sockaddr,$addr); my @inetaddr = unpack('C4',$inetaddr); #print "$af $port @inetaddr\n"; my $ctr=0; while (my $t=<NS>) { $ctr++; if( substr($t,0,4) eq "QUIT") { send(NS,"221 Bye\r\n",0); last; } print $t; #print FIL $t; if( substr($t,0,1) eq '.') { send(NS,"250 okey-dokey\r\n",0); $bool_data = 0; next; } if($bool_data){ $mail_content .= $t; } my $x=substr($t,0,4); if( ($x eq "EHLO") ||($x eq "HELO") || ($x eq "RCPT") || ($x eq "MAIL") || ($x eq "RSET") || ($x eq "QUIT")) { send(NS,"250 " . $t . " okey-dokey\r\n",0); } if($x eq "DATA"){ send(NS,"354 End data with .\r\n",0); $bool_data = 1; } } close(NS); analyse_email($mail_content); } sub analyse_email{ my $mail = shift; print "\n\nEMAIL:\n".$mail; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
1: > 220 mail.example.com SMTP Foo Mailserver
2: < HELO mail.example.org
3: > 250 Ok
4: < MAIL FROM: hans.muster@example.org
5: > 250 Ok
6: < RCPT TO: foo@example.com
7: > 250 Ok
8: < DATA
9: > 354 End data with .
10: < From: hans.muster@example.org
11: < To: foo@example.com
12: < Subject: Testmail
13: <
14: < Testmail
15: < .
16: > 250 Ok
17: < QUIT
18: > 221 Bye