Synology: E-Mails mit „nail“ an ein Postfach bei united-hoster.de versenden

Fazit:

Das Synology NAS kann E-Mails mit dem Programm „nail“ direkt von der Konsole oder einem Script versenden. Bei mir hat es nicht auf Anhieg geklappt.

Nachdem der Provider empfohlen hatte, eine neue OpenSSL Version zu testen, wurde die Fehlersuche aufgegeben. Die Übertragung erfolgt bis auf Weiteres unverschlüsselt.

Aber nun der Reihe nach:


 

Ich möchte die Datei messages verschicken:

echo "test" | nail -v -s "test" -a "/var/log/messages" roman@krakovic.de

Zurück kommt:

Resolving host exchange-smtp.united-hoster.de . . . done.
Connecting to 81.20.130.98 . . .
DiskStation> could not connect: Connection timed out
"/root/dead.letter" 518/49842
. . . message not sent.

Ich denke, dass mit der Config was nicht stimmt. Nail wird laut WIKI hier konfiguriert:

/opt/etc/nail.rc
set smtp=smtps://exchange-smtp.united-hoster.de:465
set from="diskstation@krakovic.de"
set smtp-auth=login
set smtp-auth-user=******
set smtp-auth-password=****
set ssl-verify=ignore

Sehr wahrscheinlich gibt es ein Problem mit SMTP und dem Port bei United-Hoster.de
Nach der Umstellung auf SMTP klappt es zuerst, aber nicht ganz:

DiskStation> echo "test" | nail -v -s "jkl" -a "/var/log/messages" ABC@XYZ.de
Resolving host exchange-smtp.united-hoster.de . . . done.
Connecting to 81.20.130.98 . . . connected.
220 exchange-smtp.united-hoster.de Microsoft ESMTP MAIL Service ready at Mon, 3 Aug 2015 10:25:49 +0200
>>> EHLO DiskStation
250-exchange-smtp.united-hoster.de Hello [178.19.226.141]
250-SIZE 104857600
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-AUTH GSSAPI NTLM LOGIN
250-8BITMIME
250-BINARYMIME
250 CHUNKING
>>> AUTH LOGIN
334 VXNlcm5hbWU6
>>> cm9tYW5Aa3Jha292aWMuZGU=
334 UGFzc3dvcmQ6
>>> cjIyMDU2Nio=
235 2.7.0 Authentication successful
>>> MAIL FROM: <diskstation@krakovic.de>
250 2.1.0 Sender OK
>>> RCPT TO: <**********>
250 2.1.5 Recipient OK
>>> DATA
354 Start mail input; end with <CRLF>.<CRLF>
>>> .
550 5.7.1 Client does not have permissions to send as this sender
smtp-server: 550 5.7.1 Client does not have permissions to send as this sender
"/root/dead.letter" 0/0
. . . message not sent.
DiskStation>

Der Server hat ein Problem damit, dass E-Mails „von Außen“ aus dem Internet zugestellt werden, er verfügt jedoch über den MX-Record für meine Domain.
Ändern wir den Absender:

set smtp=smtp://exchange-smtp.united-hoster.de:25
set from="diskstation@FAKEDOMAIN.de"
set smtp-auth=login
set smtp-auth-user=********
set smtp-auth-password=******
set ssl-verify=ignore

Nun funktioniert es – aber nur mit einem unverschlüsselten SMTP.

Der Provider united-hoster.de meint, smtps würde auch über Port 25 laufen. Das führt aber zu diesem Fehler:

DiskStation> ./testnail.sh
DiskStation> could not initiate SSL/TLS connection: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
"/root/dead.letter" 11/343
. . . message not sent

Hier und hier urde das Thema auch diskutiert.

Hinweis:

This error happens when OpenSSL receives something other than a ServerHello in a protocol version it understands from the server. It can happen if the server answers with a plain (unencrypted) HTTP. It can also happen if the server only supports e.g. TLS 1.2 and the client does not understand that protocol version. Normally, servers are backwards compatible to at least SSL 3.0 / TLS 1.0, but maybe this specific server isn’t (by implementation or configuration).

Jetzt muss man also SSL untersuchen, indem eine Verbindung per OPENSSL aufgebaut wird, zuerst zu 1&1

DiskStation> openssl s_client -connect smtp.1und1.de:587 -starttls smtp
CONNECTED(00000003)
depth=2 /C=DE/O=Deutsche Telekom AG/OU=T-TeleSec Trust Center/CN=Deutsche Telekom Root CA 2
verify error:num=19:self signed certificate in certificate chain
verify return:0
---
Certificate chain
 0 s:/C=DE/O=1 und 1 Internet AG/ST=Rheinland-Pfalz/L=Montabaur/emailAddress=server-certs@1und1.de/CN=smtp.1und1.de
   i:/C=DE/O=T-Systems International GmbH/OU=T-Systems Trust Center/ST=NRW/postalCode=57250/L=Netphen/street=Untere Indu           striestr. 20/CN=TeleSec ServerPass DE-1
 1 s:/C=DE/O=T-Systems International GmbH/OU=T-Systems Trust Center/ST=NRW/postalCode=57250/L=Netphen/street=Untere Indu           striestr. 20/CN=TeleSec ServerPass DE-1
   i:/C=DE/O=Deutsche Telekom AG/OU=T-TeleSec Trust Center/CN=Deutsche Telekom Root CA 2
 2 s:/C=DE/O=Deutsche Telekom AG/OU=T-TeleSec Trust Center/CN=Deutsche Telekom Root CA 2
   i:/C=DE/O=Deutsche Telekom AG/OU=T-TeleSec Trust Center/CN=Deutsche Telekom Root CA 2
---
Server certificate
-----BEGIN CERTIFICATE-----
.. gekürzt..
puNDXW5M+/FFNBa63ea4e7MEXKv6zF2pVfPaOA/stqGZIQ==
-----END CERTIFICATE-----
subject=/C=DE/O=1 und 1 Internet AG/ST=Rheinland-Pfalz/L=Montabaur/emailAddress=server-certs@1und1.de/CN=smtp.1und1.de
issuer=/C=DE/O=T-Systems International GmbH/OU=T-Systems Trust Center/ST=NRW/postalCode=57250/L=Netphen/street=Untere In           dustriestr. 20/CN=TeleSec ServerPass DE-1
---
No client certificate CA names sent
---
SSL handshake has read 5631 bytes and written 488 bytes
---
New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : DHE-RSA-AES256-SHA
    Session-ID: 4DF6D465F67677EF14BD85613C987E0C25C60E003D33E2C413F3F2BC4C3A5013
    Session-ID-ctx:
    Master-Key: 3C48EEE6DC62967E6BF9157E14D944D525EC4E97238E8B9253313AA34EDD2CD865005F786571DD64706AA209F7B7ED83
    Key-Arg   : None
    Start Time: 1438599929
    Timeout   : 300 (sec)
    Verify return code: 19 (self signed certificate in certificate chain)
---
250 STARTTLS
421 kundenserver.de Service closing transmission channel - command timeout
closed


Und nun zu united-hoster.de

DiskStation> openssl s_client -connect exchange-smtp.united-hoster.de:25 -starttls smtp
CONNECTED(00000003)
depth=1 /C=US/O=Thawte, Inc./OU=Domain Validated SSL/CN=Thawte DV SSL CA
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
 0 s:/OU=Go to https://www.thawte.com/repository/index.html/OU=Thawte SSL123 certificate/OU=Domain Validated/CN=exchange-smtp.united-hoster.de
   i:/C=US/O=Thawte, Inc./OU=Domain Validated SSL/CN=Thawte DV SSL CA
 1 s:/C=US/O=Thawte, Inc./OU=Domain Validated SSL/CN=Thawte DV SSL CA
   i:/C=US/O=thawte, Inc./OU=Certification Services Division/OU=(c) 2006 thawte, Inc. - For authorized use only/CN=thawte Primary Root CA
---
Server certificate
-----BEGIN CERTIFICATE-----
.. gekürzt..
uVEfHJnS883S+KGhbOKXIGzIku2mS0dyaJNTaIXm7ZehuIXuUgZe2jayh19ePffW
427NKmCotLvpeGHE1chRXQYG2to+UAMaGeSPMtD0WYoIfi4bB/I7t1Nw97J3oXuL
jg7WJNIZkp0iGfoflQ+/NZmrOcXJSNxv886epZUSU/mITi3Hw3F3oOlr7NZ21zGh
A7J+kFZW5JG56YhA7n599Q/3SO9l1R40YmcsB4x/ni6jXsy98wkjTA==
-----END CERTIFICATE-----
subject=/OU=Go to https://www.thawte.com/repository/index.html/OU=Thawte SSL123 certificate/OU=Domain Validated/CN=exchange-smtp.united-hoster.de
issuer=/C=US/O=Thawte, Inc./OU=Domain Validated SSL/CN=Thawte DV SSL CA
---
No client certificate CA names sent
---
SSL handshake has read 2970 bytes and written 488 bytes
---
New, TLSv1/SSLv3, Cipher is AES128-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : AES128-SHA
    Session-ID: 650300004B99A5E43ED236797070D44DB6573EF198E0EA5FC5ED864160AF544D
    Session-ID-ctx:
    Master-Key: AABEEDB8705AB8E15EC311A330E5EEB7564DB20FF6CA76D569B7E4DD7BF696AAA5594D6FF34AFA4B9AC1DA79B1F27F59
    Key-Arg   : None
    Start Time: 1438600269
    Timeout   : 300 (sec)
    Verify return code: 20 (unable to get local issuer certificate)
---
250 CHUNKING

Die beiden Ausgaben unterscheiden sich. 1&1 liefert am Ende 250-STARTTLS und united-hoster.de 250-CHUNKING.

…..nächsten Hinweis gefunden:

I’m having a very similar issue with the SMTP-IMAP Round Trip sensor. I get the error „Error connecting with SSL. error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version“. From my research it appears that PRTG may be trying to connect directly to port 587 when outlook.com is expecting a STARTTLS command first before it begins encrypted communication. I have no proof, but it seems that this is the issue.

Fazit: Nachdem der Provider empfohlen hatte eine neue OpenSSL Version zu testen, wurde die Fehlersuche aufgegeben. Die Übertragung erfolgt bis auf Weiteres unverschlüsselt.