Skip to content

Commit

Permalink
smtp client
Browse files Browse the repository at this point in the history
  • Loading branch information
Kibet-mutai committed Mar 29, 2024
1 parent 6dbc91a commit 3da8258
Show file tree
Hide file tree
Showing 4 changed files with 483 additions and 0 deletions.
283 changes: 283 additions & 0 deletions smtp/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions smtp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "smtp"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
chrono = "0.4.37"
47 changes: 47 additions & 0 deletions smtp/smtp_dialog.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
In a typical session, SMTP dialog works as follows:
- The client first establishes connection to the SMTP server.
- The server initiates with a greeting. This greeting indicates that the server is ready to receive commands.
- The client then issues its own greeting.
- Server responds.
- the client sends a command indicating who the mail is from.
- The server responds to indicate that the sender is accepted.
- The client issues anaother command, which specifies the mail recipient.
- The server responds indicating the recipient is accepted.
- The client then issues a DATA command.
- The server responds asking the client to proceed.
- The client transfers the email.

Example:
S: 220 mail.example.com SMTP server ready
C: HELO mail.example.net
S: 250 Hello mail.example.net [192.0.2.67]
C: MAIL FROM:<alice@example.net>
S: 250 OK
C: RCPT TO:<bob@example.com>
S: 250 Accepted
C: DATA
S: 354 Enter message, ending with "." on a line by itself
C: Subject: Re: The Cake
C: Date: Fri, 03 May 2019 02:31:20 +0000
C:
C: Do NOT forget to bring the cake!
C: .
S: 250 OK
C: QUIT
S: 221 closing connection

The common client commands we use are as follows:
HELO is used for the client to identify itself to the server.
MAIL is used to specify who is sending the mail.
RCPT is used to specify a recipient.
DATA is used to initiate the transfer of the actual email. This email
should include both headers and a body.
QUIT is used to end the session.

The server response codes used in a successful email transfer are the
following:
220: The service is ready
250: The requested command was accepted and completed successfully
354: Start sending the message
221: The connection is closing
Error codes vary between providers, but they are generally in the 500 range.
Loading

0 comments on commit 3da8258

Please sign in to comment.