---
title: "Sending images over 7-bit ASCII SMTP"
subject: "Computer Networks and Security"
chapter: 6
key: "semester_7/computer_networks_and_security:smtp-images-mime"
source: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/smtp-images-mime
site: BCT Engineering
---

# Sending images over 7-bit ASCII SMTP

Computer Networks and Security · Chapter 6: Application Layer

- Asked in: 2071 Shrawan, 8 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/smtp-images-mime
- Whole chapter: https://www.bctengineer.com/md/semester_7/computer_networks_and_security/chapter-6

## Question

SMTP is a text based protocol and uses 7 bit ASCII. How can this be used to transmit something like images? Explain.

## 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.

## Answer

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
```text
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.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Why can SMTP not carry images directly?
   A. It is limited to 7-bit ASCII and images contain bytes above 127
   B. It is too slow
   C. It uses UDP
   D. It lacks ports
   Answer: A. Binary bytes above 127 are not allowed in 7-bit SMTP. (Key point: Problem)

2. How does MIME solve it?
   A. Changes SMTP
   B. Encodes non-ASCII data into ASCII at sender and decodes at receiver
   C. Compresses the image
   D. Uses POP3
   Answer: B. MIME converts to ASCII without changing SMTP. (Key point: MIME solution)

3. How does base64 encode data?
   A. 3 bytes into four 6-bit groups mapped to printable characters
   B. 4 bytes into three groups
   C. 1 byte into 2 characters
   D. Each bit to a character
   Answer: A. 24 bits split into four 6-bit values. (Key point: Base64)

4. How much larger is base64 output?
   A. Same size
   B. 4/3 (about 33% bigger)
   C. Twice
   D. Half
   Answer: B. 300 bytes become 400 characters. (Key point: Size)

## Related in Computer Networks and Security

- [Short note: SMTP](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Asmtp-note) — Computer Networks and Security, chapter 6

## Related in other subjects

- [8086 speed over 8-bit; major registers](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3A8086-faster-registers) — Microprocessor, chapter 3
- [RS-232C importance; time to transmit a string at 4800 baud](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Ars232c-string-time-4800) — Instrumentation II, chapter 3
- [Fibre uses; pros and cons over metal wire](https://www.bctengineer.com/question.md?key=semester_6%2Fpropagation_and_antenna%3Afiber-uses-advantages-metal-wire) — Propagation and Antenna, chapter 6, asked 2×
- [Bitmap images; bitmap versus vector](https://www.bctengineer.com/question.md?key=semester_8%2Fmultimedia_system%3Abitmap-images-vs-vector) — Multimedia System, chapter 3
