Email send and check in Linux comand line

Posted on Tue 20 December 2005

Example: mail box me\@khmel.org, login: "me", password: "testpass".

1. Send e-mail

# Connect to server on TCP 25 port
$ telnet smtp.khmel.org 25
Trying 127.0.0.1...
Connected to smtp.khmel.org.
Escape character is '^]'.
220 smtp.khmel.org ESMTP Postfix

EHLO

# Sender:
MAIL FROM: <me@khmel.org>
250 Ok

# To:
RCPT TO: <test@khmel.org>
250 Ok

# E-Mail text after command DATA:

DATA
354 End data with .
Hello test.

# To end you can press ENTER, then DOT "." and again ENTER. Success:
250 Ok: queued as 822A958

2. Check email (POP3)

# Connect to POP3 server:
$ telnet pop.khmel.org 110
Trying 127.0.0.1...
Connected to pop.khmel.org.
Escape character is '^]'.
+OK

# Login and password:
user me
+OK
pass testpass
+OK

# Mail box status:
stat
+OK 1 597

# There is 1 mail with size 597. Show first 20 lines:
top 1 20
+OK
Return-Path: <test@khmel.org test@khmel.org >
Received: (from test@khmel.orgtest@khmel.org )
for test@khmel.orgtest@khmel.org ; Tue, 11 Feb 2003 18:18:39 +0300 (MSK)
(envelope-from test@khmel.orgtest@khmel.org )
Date: Tue, 11 Feb 2003 18:18:39 +0300 (MSK)
From: tester < test@khmel.org >
Message-Id: <200302111518.h1BFIdO44983@khmel.org200302111518.h1BFIdO44983@khmel.org>
To: me
I am ok

# Logout:
quit
+OK
Connection closed by foreign host.