SMTP: notes and tips This note was created on 2024-04-03 This note was last edited on 2024-04-03 === How to debug SMTP server using telnet === Using Telnet to debug email can provide insights into SMTP communication issues and help diagnose problems with email delivery. However, note that modern email servers may require authentication or encryption, which Telnet cannot provide. 1. Connect to the SMTP Server: $ telnet smtp.example.com 25 2. Introduce yourself to the server: > EHLO mydomain.com 3. Specify the sender's email address: > MAIL FROM: 4. Specify the recipient's email address: > RCPT TO: 5. Start the email content: > DATA 6. Specify the subject: > Subject: Your Subject 7. Write the body text. End with a single period (".") on a new line to indicate the end of the email content. 8. Close the connection: > QUIT === SMTP session example === $ telnet smtp.example.com 25 > EHLO mydomain.com > MAIL FROM: > RCPT TO: > DATA > Subject: Test Email > Hello, > This is a test email. > . > QUIT === Server Response Codes === The three digits of the reply each have a special significance. There are five values for the first digit of the reply code: - 1yz: Positive Preliminary reply. - 2yz: Positive Completion reply. - 3yz: Positive Intermediate reply. - 4yz: Transient Negative Completion reply. - 5yz: Permanent Negative Completion reply. The second digit encodes responses in specific categories: - x0z: Syntax. - x1z: Information. - x2z: Connections. - x3z: Unspecified. - x4z: Unspecified. - x5z: Mail system. The third digit gives a finer gradation of meaning in each category specified by the second digit. 2YZ Positive Completion replies: - 211: System status, or system help reply. - 214: Help message. - 220: Service ready. - 221: Service closing transmission channel. - 250: Requested mail action okay, completed. - 251: User not local; will forward to . 3YZ Positive Intermediate replies: - 354: Start mail input; end with .. 4YZ Transient Negative Completion replies: - 421: Service not available, closing transmission channel. - 450: Requested mail action not taken: mailbox unavailable. - 451: Requested action aborted: local error in processing. - 452: Requested action not taken: insufficient system storage. 5YZ Permanent Negative Completion replies: - 500: Syntax error, command unrecognized (may include errors such as command line too long). - 501: Syntax error in parameters or arguments. - 502: Command not implemented. - 503: Bad sequence of commands. - 504: Command parameter not implemented. - 550: Requested action not taken: mailbox unavailable (not found or no access). - 551: User not local; please try . - 552: Requested mail action aborted: exceeded storage allocation. - 553: Requested action not taken: mailbox name not allowed (e.g. mailbox syntax incorrect). - 554: Transaction failed. To learn more about SMTP status codes, see RFC 821 and 3463.