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
#!/usr/bin/perl use warnings; use strict; use Net::SMTP; send_mail('hi', 'test-msg', ['stefan@example.com']); sub send_mail { my $sub = shift; my $msg = shift; my $to = shift; my $pid = fork(); if ( !defined $pid ) { die "Cannot fork: $!"; } elsif ( $pid == 0 ) { #child die "Recipients need to be array-ref." unless ref $to eq 'ARRAY'; my $smtp = Net::SMTP->new("mail.example.com", Port => 587, Debug => 1) or die $!; my $from = 'robot@example.com'; $smtp->starttls( SSL_verify_mode => 0 ); $smtp->auth('robot@example.com', 'PASS'); $smtp->mail($from); $smtp->to( @$to ); $smtp->data(); $smtp->datasend('Date: ' . localtime( time() ) . "\n" ); $smtp->datasend("From: $from\n"); $smtp->datasend('To: ' . join(',', @$to) . "\n"); $smtp->datasend("Subject: $sub\n"); $smtp->datasend("\n"); $smtp->datasend("$msg\n\n"); $smtp->dataend; $smtp->quit; exit 0; } }
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
styx@HermesWWW:~/dev-prod/dev/SMA$ perl SendEmail.pl
styx@HermesWWW:~/dev-prod/dev/SMA$ Net::SMTP>>> Net::SMTP(3.08_01)
Net::SMTP>>> Net::Cmd(3.08_01)
Net::SMTP>>> Exporter(5.72)
Net::SMTP>>> IO::Socket::IP(0.37)
Net::SMTP>>> IO::Socket(1.38)
Net::SMTP>>> IO::Handle(1.36)
Net::SMTP=GLOB(0x55cc2bf21b80)<<< 220 mail.example.com ESMTP Postfix
Net::SMTP=GLOB(0x55cc2bf21b80)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x55cc2bf21b80)<<< 250-mail.example.com
Net::SMTP=GLOB(0x55cc2bf21b80)<<< 250-PIPELINING
Net::SMTP=GLOB(0x55cc2bf21b80)<<< 250-SIZE 52428800
Net::SMTP=GLOB(0x55cc2bf21b80)<<< 250-VRFY
Net::SMTP=GLOB(0x55cc2bf21b80)<<< 250-ETRN
Net::SMTP=GLOB(0x55cc2bf21b80)<<< 250-STARTTLS
Net::SMTP=GLOB(0x55cc2bf21b80)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP=GLOB(0x55cc2bf21b80)<<< 250-8BITMIME
Net::SMTP=GLOB(0x55cc2bf21b80)<<< 250-DSN
Net::SMTP=GLOB(0x55cc2bf21b80)<<< 250 CHUNKING
Net::SMTP=GLOB(0x55cc2bf21b80)>>> STARTTLS
Net::SMTP=GLOB(0x55cc2bf21b80)<<< 220 2.0.0 Ready to start TLS
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)>>> EHLO localhost.localdomain
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 250-mail.example.com
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 250-PIPELINING
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 250-SIZE 52428800
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 250-VRFY
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 250-ETRN
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 250-AUTH PLAIN LOGIN
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 250-8BITMIME
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 250-DSN
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 250 CHUNKING
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)>>> AUTH PLAIN df9ib3RAcG9tZXJlcmlnLmRlAHJvYm90JDUvbWVyZXJpZy5kPOI0M0UwM01IcjHgFlO=
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 235 2.7.0 Authentication successful
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)>>> MAIL FROM:<robot@example.com>
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 250 2.1.0 Ok
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)>>> RCPT TO:<stefan@example.com>
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 250 2.1.5 Ok
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)>>> DATA
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 354 End data with <CR><LF>.<CR><LF>
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)>>> Date: Wed Jul 31 23:18:52 2019
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)>>> From: robot@example.com
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)>>> To: stefan@example.com
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)>>> Subject: hi
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)>>> test-msg
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)>>> .
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 250 2.0.0 Ok: queued as 9F6EC721B52
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)>>> QUIT
Net::SMTP::_SSL=GLOB(0x55cc2bf21b80)<<< 221 2.0.0 Bye
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
stefan@dev:~/old-dev/SMA$ perl SendEmail.pl
stefan@dev:~/old-dev/SMA$ Net::SMTP>>> Net::SMTP(3.11)
Net::SMTP>>> Net::Cmd(3.11)
Net::SMTP>>> Exporter(5.73)
Net::SMTP>>> IO::Socket::IP(0.39)
Net::SMTP>>> IO::Socket(1.39)
Net::SMTP>>> IO::Handle(1.39)
Net::SMTP=GLOB(0x556995279648)<<< 220 mail.example.com ESMTP Postfix
Net::SMTP=GLOB(0x556995279648)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x556995279648)<<< 250-mail.example.com
Net::SMTP=GLOB(0x556995279648)<<< 250-PIPELINING
Net::SMTP=GLOB(0x556995279648)<<< 250-SIZE 52428800
Net::SMTP=GLOB(0x556995279648)<<< 250-VRFY
Net::SMTP=GLOB(0x556995279648)<<< 250-ETRN
Net::SMTP=GLOB(0x556995279648)<<< 250-STARTTLS
Net::SMTP=GLOB(0x556995279648)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP=GLOB(0x556995279648)<<< 250-8BITMIME
Net::SMTP=GLOB(0x556995279648)<<< 250-DSN
Net::SMTP=GLOB(0x556995279648)<<< 250 CHUNKING
Net::SMTP=GLOB(0x556995279648)>>> STARTTLS
Net::SMTP=GLOB(0x556995279648)<<< 220 2.0.0 Ready to start TLS
Net::SMTP::_SSL=GLOB(0x556995279648)>>> EHLO localhost.localdomain
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 250-mail.example.com
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 250-PIPELINING
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 250-SIZE 52428800
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 250-VRFY
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 250-ETRN
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 250-AUTH PLAIN LOGIN
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 250-8BITMIME
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 250-DSN
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 250 CHUNKING
Net::SMTP::_SSL=GLOB(0x556995279648)>>> MAIL FROM:<robot@example.com>
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 250 2.1.0 Ok
Net::SMTP::_SSL=GLOB(0x556995279648)>>> RCPT TO:<stefan@example.com>
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 554 5.7.1 <dev.example.com[78.46.xx.xx]>: Client host rejected: Access denied
Net::SMTP::_SSL=GLOB(0x556995279648)>>> DATA
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 554 5.5.1 Error: no valid recipients
Net::SMTP::_SSL=GLOB(0x556995279648)>>> Date: Wed Jul 31 23:19:43 2019
Net::SMTP::_SSL=GLOB(0x556995279648)>>> From: robot@example.com
Net::SMTP::_SSL=GLOB(0x556995279648)>>> To: stefan@example.com
Net::SMTP::_SSL=GLOB(0x556995279648)>>> Subject: hi
Net::SMTP::_SSL=GLOB(0x556995279648)>>> test-msg
Net::SMTP::_SSL=GLOB(0x556995279648)>>> .
Net::SMTP::_SSL=GLOB(0x556995279648)<<< 221 2.7.0 Error: I can break rules, too. Goodbye.
Net::SMTP::_SSL=GLOB(0x556995279648)>>> QUIT
1
2
Net::SMTP::_SSL: Net::Cmd::_syswrite_with_timeout(): unexpected EOF on command channel: Connection reset by peer at Se
ndEmail.pl line 44.
use IO::Socket::SSL qw(debug3);
1
2
3
4
Aug 1 17:28:07 mail postfix/submission/smtpd[359]: connect from dev.example.com[78.46.xx.xx]
Aug 1 17:28:07 mail postfix/submission/smtpd[359]: NOQUEUE: reject: RCPT from dev.example.com78.46.xx.xx]: 554 5.7.1 <dev.example.com[78.46.xx.xx]>: Client host rejected: Access denied; from=<robot@example.com> to=<stefan@example.com> proto=ESMTP helo=<localhost.localdomain>
Aug 1 17:28:07 mail postfix/submission/smtpd[359]: warning: non-SMTP command from dev.example.com[78.46.xx.xx]: Date: Thu Aug 1 17:28:07 2019
Aug 1 17:28:07 mail postfix/submission/smtpd[359]: disconnect from dev.example.com[78.46.xx.xx] ehlo=2 starttls=1 mail=1 rcpt=0/1 data=0/1 unknown=0/1 commands=4/7
2019-08-01T20:37:28 thomas38Verdächtig finde ich folgend Zeile:
[...]Client host rejected: Access denied; from=<robot@example.com> to=<stefan@example.com> proto=ESMTP helo=<localhost.localdomain>
QuoteVermutlich verlangt postfix aber pingeligerweise den richtigen hostnamen (hier vermutlich dev.example.com).
2019-08-02T06:23:48 GwenDragon2019-08-01T20:37:28 thomas38Verdächtig finde ich folgend Zeile:
[...]Client host rejected: Access denied; from=<robot@example.com> to=<stefan@example.com> proto=ESMTP helo=<localhost.localdomain>
localhost.localdomain ein kein gültiger FQDN.
QuoteVermutlich verlangt postfix aber pingeligerweise den richtigen hostnamen (hier vermutlich dev.example.com).
Was heißt pingelig? Das SMTP-Protokoll verlangt einen FQDN
https://tools.ietf.org/html/rfc5321#section-2.3.5
Und den FQDN bei HELO zu testen dient dazu Spammer zu blocken http://unixwiz.net/techtips/postfix-HELO.html
1
2
3
4
5
The domain name given in the EHLO command MUST be either a primary
host name (a domain name that resolves to an address RR) or, if
the host has no name, an address literal, as described in
Section 4.1.3 and discussed further in the EHLO discussion of
Section 4.1.4.
1
2
3
4
5
6
7
8
9
10
[...]
An SMTP server MAY verify that the domain name argument in the EHLO
command actually corresponds to the IP address of the client.
However, if the verification fails, the server MUST NOT refuse to
accept a message on that basis. Information captured in the
verification attempt is for logging and tracing purposes. Note that
this prohibition applies to the matching of the parameter to its IP
address only; see Section 7.9 for a more extensive discussion of
rejecting incoming connections or mail messages.
[...]
QuoteThe domain name given in the EHLO command MUST be either a primary
host name (a domain name that resolves to an address RR) or, if
the host has no name, an address literal
Quote(…) verify that the domain name argument in the EHLO
command actually corresponds to the IP address of the client.
However, if the verification fails, the server MUST NOT refuse to
accept a message on that basis (…)
2019-08-01T06:58:26 rostiKryptomanie? Ist ja schon krankhaft!SSL ist eine gute Idee
2019-08-01T12:34:15 Daxim2019-08-01T06:58:26 rostiKryptomanie? Ist ja schon krankhaft!SSL ist eine gute Idee