- 2071 Shrawan · 8 marks
Sending images over 7-bit ASCII SMTP
Short answer
SMTP carries only 7-bit ASCII, so binary data is converted using MIME. Base64 encodes 3 bytes into four printable ASCII characters, and MIME headers such as Content-Type and Content-Transfer-Encoding let the receiver decode and display the image.
SMTP is a text based protocol and uses 7 bit ASCII. How can this be used to transmit something like images? Explain.
SMTP can only carry 7-bit ASCII lines. Binary data such as images, audio, and non-English text contains bytes above 127, which SMTP cannot transmit directly. The solution is MIME (Multipurpose Internet Mail Extensions), which converts non-ASCII data to ASCII at the sender and converts it back at the receiver, without changing SMTP itself.
MIME headers added to the message
| Header | Purpose |
|---|---|
| MIME-Version: 1.0 | Message uses MIME |
| Content-Type | Type of data: text/plain, image/jpeg, application/pdf, multipart/mixed |
| Content-Transfer-Encoding | How the data was converted to ASCII: 7bit, quoted-printable, base64 |
| Content-Disposition / Content-ID | Attachment name, inline display |
Base64 encoding
Base64 takes 3 bytes (24 bits), splits them into four 6-bit groups, and maps each group (0 to 63) to a printable character (A-Z, a-z, 0-9, +, /). Padding = is used if bytes are missing.
Example: text "Man"
| Character | M | a | n |
|---|---|---|---|
| ASCII bits | 01001101 | 01100001 | 01101110 |
6-bit groups: 010011 | 010110 | 000101 | 101110 = 19, 22, 5, 46 = T W F u. So "Man" becomes TWFu.
The encoded size is 4/3 of the original (about 33% bigger): 300 bytes become 400 characters.
Example message with an image
From: a@x.com
To: b@y.com
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="XYZ"
--XYZ
Content-Type: text/plain
Photo attached.
--XYZ
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
/9j/4AAQSkZJRgABAQ... (encoded image)
--XYZ--
The receiving user agent reads the headers, decodes the base64 part back to the original bytes and shows the image. In this way the text-based, 7-bit SMTP carries images.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Short note: SMTP · Computer Networks and Security, chapter 6
- 8086 speed over 8-bit; major registers · Microprocessor, chapter 3
- RS-232C importance; time to transmit a string at 4800 baud · Instrumentation II, chapter 3
- Fibre uses; pros and cons over metal wire · Propagation and Antenna, chapter 6 · asked 2×
- Bitmap images; bitmap versus vector · Multimedia System, chapter 3