Protocol 62 of 81Layer 7FrameAssembly v3.1.2
llms-full.txt
smtpSimple Mail Transfer Protocol

Mail Relay Conversations (mta1 <-> mta2 smtp: EHLO -> MAIL FROM -> DATA)

Default Port / Protocol
TCP 25 (or dstport 587 Submission)
Host Endpoint Rule
Dual-Stack IPv4/IPv6
Wireshark Display Filter
smtp
Standards & Specs
RFC 5321
Wire Stack:Ethernet II[802.1Q / QinQ / MPLS]IPv4 / IPv6TCP 25 (or dstport 587 Submission)SMTP

What It Does on the Wire

Step through a real RFC 5321 mail relay (220 greeting -> ehlo -> mailfrom -> rcptto -> 354 -> body -> 250 OK) over stateful TCP 25 to test mail-gateway DLP and open-relay signatures.

Simple Mail Transfer Protocol (smtp, RFC 5321) relays email between Mail Transfer Agents (MTAs) on TCP port 25 and mail submission gateways on TCP port 587. An SMTP envelope steps through server 220 greeting -> client EHLO -> MAIL FROM:<...> -> RCPT TO:<...> -> DATA (354) -> RFC 5322 message body -> 250 acceptance -> QUIT (221).

FrameAssembly gives you clean keywords for every envelope command (ehlo, helo, mailfrom, rcptto, data, quit, or custom cmd) plus code / reply for server responses and body for message content.

Test Rogue Internal Spambot & Port 25 Egress Blocks

Verify that workstation VLANs are blocked from sending direct TCP 25 SMTP traffic except through your approved Secure Email Gateway.

Validate Phishing Header, Sender Spoofing & DLP IDS Signatures

Build a full SMTP conversation (ehlo -> mailfrom -> rcptto -> data -> body) to test Suricata smtp rules and Zeek smtp.log extraction safely.

Open-Relay Rejection (code 550) Troubleshooting

Capture code 550 reply "5.7.1 Relaying denied" responses to test alerting on unauthorized mail relay attempts.

Minimal Quickstart (smtp_quickstart.frasm)

Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.

smtp_quickstart.frasm11 lines
Open in Playground
host app_srv { ip 10.20.10.15 }
host mail_gw { ip 10.20.10.25 }
compile {
app_srv -> mail_gw tcp syn srcport 51025 dstport 25 wait 1ms
app_srv <- mail_gw tcp syn ack wait 1ms
app_srv -> mail_gw tcp ack wait 1ms
app_srv <- mail_gw smtp code 220 reply "mx01.corp.internal ESMTP Postfix" wait 2ms
app_srv -> mail_gw smtp ehlo "app01.corp.internal" wait 2ms
app_srv <- mail_gw smtp code 250 reply "mx01.corp.internal"
}

What the Compiler Calculates So You Don't Have To

  • Defaults to TCP destination port 25 (psh ack; use dstport 587 for submission) and terminates SMTP lines with .
  • Formats MAIL FROM:<...> (mailfrom) and RCPT TO:<...> (rcptto) cleanly and terminates body payloads with . when needed.
  • Tracks TCP sequence and acknowledgment numbers automatically across the full multi-step envelope.
Multi-Frame Lab · Ready to Compile

Complete End-to-End RFC 5321 Email Delivery Transaction

Walks through a full TCP 25 session from 220 banner and EHLO through MAIL FROM, RCPT TO, DATA (354), message headers/body, 250 Queued, and QUIT.

smtp_full_envelope.frasm21 lines
Open in Playground
host alert_bot { ip 172.16.15.20 }
host smtp_relay { ip 172.16.15.25 }
compile {
alert_bot -> smtp_relay tcp syn srcport 52025 dstport 25 win 65535 mss 1460 wait 1ms
alert_bot <- smtp_relay tcp syn ack win 65535 mss 1460 wait 1ms
alert_bot -> smtp_relay tcp ack wait 1ms
alert_bot <- smtp_relay smtp code 220 reply "relay.corp.internal ESMTP" wait 2ms
alert_bot -> smtp_relay smtp ehlo "alert-bot.corp.internal" wait 1ms
alert_bot <- smtp_relay smtp code 250 reply "PIPELINING" wait 1ms
alert_bot -> smtp_relay smtp mailfrom "<noc-alerts@corp.internal>" wait 1ms
alert_bot <- smtp_relay smtp code 250 reply "2.1.0 Ok" wait 1ms
alert_bot -> smtp_relay smtp rcptto "<oncall@corp.internal>" wait 1ms
alert_bot <- smtp_relay smtp code 250 reply "2.1.5 Ok" wait 1ms
alert_bot -> smtp_relay smtp data wait 1ms
alert_bot <- smtp_relay smtp code 354 reply "End data with <CR><LF>.<CR><LF>" wait 2ms
alert_bot -> smtp_relay smtp body "Subject: Core Link Down\r\nFrom: noc-alerts@corp.internal\r\n\r\nGi1/0/49 went down.\r\n." wait 2ms
alert_bot <- smtp_relay smtp code 250 reply "2.0.0 Ok: queued as 9F4A1" wait 1ms
alert_bot -> smtp_relay smtp quit wait 1ms
alert_bot <- smtp_relay smtp code 221 reply "2.0.0 Bye"
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show smtp_full_envelope.frasm

# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly smtp_full_envelope.frasm smtp_full_envelope.pcap
frameassembly smtp_full_envelope.frasm smtp_full_envelope.pcapng

# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse smtp_full_envelope.pcap smtp_full_envelope_edited.frasm

All smtp Keywords & Header Options

Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after smtp:

src_host -> dst_host smtp [ehlo ["<domain>"] | helo ["<domain>"] | mailfrom "<addr>" | rcptto "<addr>" | data | quit | cmd "<verb>" [param "<text>"]] [code <200..599>] [reply "<text>"] [body "<text>"]
Keyword / OptionAccepted ValueDefaultEffect on Packet
ehlo ["<domain>"] | helo ["<domain>"]Extended or classic SMTP greeting + client hostname"localhost"Writes EHLO <domain> or HELO <domain> .
mailfrom "<addr>" | rcptto "<addr>"Quoted sender or recipient email addressOmitted unless setWrites MAIL FROM:<addr> or RCPT TO:<addr> .
data | quit | cmd "<verb>" [param "<text>"]Envelope command or custom verb (e.g. cmd "STARTTLS")OmittedWrites DATA , QUIT , or <verb> <param> .
code <200..599> [reply "<text>"]3-digit SMTP reply code (220, 250, 354, 421, 550) + textOmitted on client commandsEmits a server reply line (250 2.0.0 Ok ).
body "<text>"Quoted RFC 5322 email headers + message bodyEmptyTransmits the email message payload following 354 DATA acceptance.

Cross-Layer Wrappers Valid with smtp

802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol

11 options
OptionRange / FormatDefaultEffect on Packet
wait <number><ns|us|ms|s|m>Time gap (ns, us, ms, s, m)10msAdvances the packet timestamp clock after sending this packet and before the next packet (wait 0ns sends back-to-back).
payload "<text>" | hexpayload "<hex>"Quoted text or hex bytes (choose one)OmittedAppends or overrides raw payload bytes ("deadbeef" or "de:ad:be:ef") and updates packet lengths and checksums.
srcmac <mac> | dstmac <mac>Colon, hyphen, or Cisco dot MACHost MAC / RFC multicast MACOverrides the 14-byte Ethernet II source or destination MAC address for this single packet.
vlan <0..4095> [pcp <0..7>] [dei <0|1>]VLAN ID 0..4095, PCP 0..7, DEI 0..1UntaggedWraps the packet in an IEEE 802.1Q VLAN tag (0x8100) with optional 802.1p QoS priority.
qinq <0..4095> [innervlan <0..4095>]Outer S-VLAN 0..4095, Inner C-VLAN 0..4095Untagged (innervlan 1 when qinq is set)Double-tags the packet with outer IEEE 802.1ad S-Tag (0x88a8) plus inner IEEE 802.1Q C-Tag (0x8100).
mpls <0..1048575> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>]Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255Unlabeled (at most 1 mpls tag per packet)Inserts a 32-bit MPLS label header (0x8847) ahead of the Layer 3 header.
ttl <0..255> [dscp <0..63>] [ecn <0..3>]TTL/Hop Limit 0..255, DSCP 0..63, ECN 0..3ttl 64, dscp 0, ecn 0Sets IPv4 TTL or IPv6 Hop Limit plus DiffServ (DSCP) and ECN QoS markings.
ipid <0..65535> [df] [mf] [fragoffset <0..8191>]IPv4 ID, DF/MF flags, fragment offset 0..8191ipid 1, flags 0, fragoffset 0Sets IPv4 Identification, Do-Not-Fragment (df), More-Fragments (mf), and fragment offset (ignored over IPv6).
flowlabel <0..1048575>20-bit IPv6 Flow Label (0..1048575)0Sets the 20-bit IPv6 Flow Label for ECMP routing tests (ignored when running over IPv4 hosts).
srcport <0..65535> | dstport <0..65535>Port number 0..65535srcport 49152 (remembered), TCP 25 (or dstport 587 Submission)Overrides source or destination port and remembers the port pair automatically on <- replies.
seq <number> | acknum <number> | win <0..65535> | syn | ack | psh | fin | rstTCP sequence/ack numbers, window size, flags & RFC 7323 optionspsh ack, win 65535, automatic TCP seq/acknumOverrides automatic TCP sequence tracking, flags, or RFC 7323 options (mss, wscale, sackperm, tsval, tsecr).

Gotchas & Quick Fixes

No Spaces or Underscores in mailfrom and rcptto

Avoid
alert_bot -> smtp_relay smtp mail_from "<a@b>" rcpt_to "<c@d>"
Valid v3.1.2 Syntax
alert_bot -> smtp_relay smtp mailfrom "<a@b>"

Send mailfrom and rcptto on separate packet lines (one SMTP command per packet, spelled with zero underscores).

Field Guide 03
Poke Stateful Firewalls, Suricata, Zeek & OT Conduits