SMTP协议是互联网标准的电子邮件的传输协议。在用户端层面,它通常用于发送电子邮件。
SMTP协议是一个基于文本的传输协议,使用有限的指令和响应码在服务器和客户端之间进行
通信。作为应用层的协议,SMTP协议使用的是TCP协议的25端口进行通信。
基本SMTP 命令:
HELO
HELO ,用于向服务器发送标识发送者
MAIL FROM
MAIL FROM:,用于指定发送者的email地址
RCPT TO
RCPT TO:,用于指定接收者的emai地址
DATA
DATA ,用于发送实际数据的开始
REST
RSET ,用于放弃此次的smtp会话事务,丢弃此次会话已经保存的sender,receipents,和mail data。
VRFY
VRFY ,用于要求接收人确认string参数
HELP
HELP [] ,用于获取求助信息
QUIT
QUIT ,用于退出smtp会话
拓展SMTP命令:
EHLO
HELO ,和HELO一样,但告知服务器使用extended smtp协议
AUTH
MAIL ,用于指定认证方式
STARTTLS
STARTTLS ,用于指定使用加密连接
SIZE
SIZE ,用于告知客户端邮件的最大大小
MAIL FROM: SIZE ,用于告知服务端发送的邮件
SMTP响应:
SMTP响应有三位数字的响应码和随后的解释文本组成。
smtp的响应码:
211 System status, or system help reply
214 Help message
[Information on how to use the receiver or the meaning of a
particular non-standard command; this reply is useful only
to the human user]
220 Service ready
221 Service closing transmission channel
250 Requested mail action okay, completed
251 User not local; will forward to
354 Start mail input; end with .
421 Service not available,
closing transmission channel
[This may be a reply to any command if the service knows it
must shut down]
450 Requested mail action not taken: mailbox unavailable
[E.g., mailbox busy]
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient system storage
500 Syntax error, command unrecognized
[This 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
[E.g., mailbox not found, 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
SMTP AUTH 方式:
LOGIN:
PLAIN:
CRAM-MD5:
SMTP 加密连接: