From aac3df99972dbd54cd02230a8635a934886411e5 Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Mon, 25 Sep 2023 20:20:00 +0200 Subject: [PATCH] add email --- data/email.md | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 data/email.md diff --git a/data/email.md b/data/email.md new file mode 100644 index 0000000..fbcbc57 --- /dev/null +++ b/data/email.md @@ -0,0 +1,73 @@ +--- +title: "e-mail" +tags: [ "data", "smtp" ] +--- + +This is bare-bones, original, primitive e-mail. + +Install `opensmtpd` (or similar), then `ncat` or `nc` or `netcat` (this mysterious cat has many names). + +Start the `opensmtpd` service, then use netcat to speak with the mail-daemon: + + +``` +nc localhost 25 +``` +The computer should respond with code `220`, which means 'I am listening'. + +> 220 hex ESMTP OpenSMTPD + +``` +HELO gmail.com +``` + +You say `HELO` and say where you are coming from. + + +The `smtpd` will not check, so I am going to lie to it. +Mail servers are easily impressed, so it will be pleased to meet you. + +> 250 hex Hello gmail.com [::1], pleased to meet you + +``` +MAIL FROM: +``` + +All the mail commands start with 4 bytes, because it's easier for admins to program. +Tell the mail daemon who you are in this format. + +> 250 2.0.0 Ok + +Then tell it who you're sending to. + +``` +RCPT TO: +``` + +> 250 2.1.5 Destination address valid: Recipient ok + +Finally, tell it that you want to send `DATA`. + +``` +DATA +``` + +> 354 Enter mail, end with "." on a line by itself + +``` +Subject: turn off server please + +very urgent +. +``` + +> 250 2.0.0 73864a49 Message accepted for delivery + +You will find the email under `/var/spool` or `/var/mail` or similar. + +If unsure, just take a part of your email, like `FRAGMENT="turn off server please"`, then `grep` for it: + + ```bash +sudo grep -r $FRAGMENT /var/spool/* + ``` +