Um die Verbindung zu einem SMTP Server zu testen um zum Beispiel einen Fehler durch eine Firewall auszuschließen nutze ich normalerweise telnet:
user@host ~ $ telnet mail.example.net 25 Trying 1.2.3.4... Connected to mail.example.net. Escape character is '^]'. 220 mail.example.net ESMTP Postfix |
Wenn telnet nicht installiert ist geht das auch noch mit netcat:
user@host ~ $ nc mail.example.net 25 220 mail.example.net ESMTP Postfix |
Heute hatte ich ein System auf dem beides nicht existierte. Da habe ich eine Methode mit python gefunden die sehr gut funktioniert hat:
user@host ~ $ python
Python 2.7.9 (default, Mar 1 2015, 12:57:24)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> conn=socket.create_connection(('mail.example.net',25))
>>> input=conn.makefile()
>>> print input.readline()
220 mail.example.net ESMTP Postfix
>>> conn.sendall('QUIT')
>>> conn.close()
>>>
evtl. existiert aber auch mbuffer (grüße von Markus aus H ;-)
Schau Dir mal swaks (http://www.jetmore.org/john/code/swaks/) an. Du wirst nie wieder etwas anderes verwenden wollen :-)