用Socket发送电子邮件二
SMTP的基础
基于TCP/IP的因特网协议一般的命令格式都是通过请求/ 应答方式实现的,采用的都是文本信息,所以处理起来要容易一些。SMTP是简单邮件传输协议的简称,它可以实现客户端向服务器发送邮件的功能。所以下面所讲的命令是指客户端向服务器发出请求指令,而响应则是指服务器返回给客户端的信息。
SMTP分为命令头和信息体两部分。命令头主要完成客户端与服务器的连接,验证等。整个过程由多条命令组成。每个命令发到服务器后,由服务器给出响应信息,一般为3 位数字的响应码和响应文本。不同的服务器返回的响应码是遵守协议的,但是响应正文本则不必。每个命令及响应的最后都有一个回车符,这样使用fputs()和fgets()就可以进行命令与响应的处理了。SMTP的命令及响应信息都是单行的。信息体则是邮件的正文部分,最后的结束行应以单独的"."作为结束行。
客户端一些常用的SMTP指令为:
HELO hostname: 与服务器打招呼并告知客户端使用的机器名字,可以随便填写
MAIL FROM: sender_id : 告诉服务器发信人的地址
RCPT TO: receiver_id : 告诉服务器收信人的地址
DATA : 下面开始传输信件内容,且最后要以只含有.的特殊行结束
RESET: 取消刚才的指令,从新开始
VERIFY userid: 校验帐号是否存在(此指令为可选指令,服务器可能不支持)
QUIT : 退出连接,结束
服务器返回的响应信息为(格式为:响应码+空格+解释):
220 服务就绪(在socket连接成功时,会返回此信息)
221 正在处理
250 请求邮件动作正确,完成(HELO,MAIL FROM,RCPT TO,QUIT指令执行成功会返回此信息)
354 开始发送数据,结束以 .(DATA指令执行成功会返回此信息,客户端应发送信息)
500 语法错误,命令不能识别
550 命令不能执行,邮箱无效
552 中断处理:用户超出文件空间

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The sudo command allows users to run commands in elevated privilege mode without switching to superuser mode. This article will introduce how to simulate functions similar to sudo commands in Windows systems. What is the Shudao Command? Sudo (short for "superuser do") is a command-line tool that allows users of Unix-based operating systems such as Linux and MacOS to execute commands with elevated privileges typically held by administrators. Running SUDO commands in Windows 11/10 However, with the launch of the latest Windows 11 Insider preview version, Windows users can now experience this feature. This new feature enables users to

Apple offers a privacy-focused feature called "Hide Email Address" that allows users to hide their real email addresses on apps or websites that require account registration. We've taught you how to use this feature on your iPhone, now let's take a look at what's possible when using it in your daily work. What is a hidden email address on iPhone? The purpose of the Hide Email Address feature is to protect the privacy of your email address. By providing a temporary email address for application and website registration, you do not need to directly provide a person's real email address. This feature allows you to generate multiple iCloud email addresses for signing up with different services, thus avoiding revealing your true email address.

This article will introduce readers to how to use the command prompt (CommandPrompt) to find the physical address (MAC address) of the network adapter in Win11 system. A MAC address is a unique identifier for a network interface card (NIC), which plays an important role in network communications. Through the command prompt, users can easily obtain the MAC address information of all network adapters on the current computer, which is very helpful for network troubleshooting, configuring network settings and other tasks. Method 1: Use "Command Prompt" 1. Press the [Win+X] key combination, or [right-click] click the [Windows logo] on the taskbar, and in the menu item that opens, select [Run]; 2. Run the window , enter the [cmd] command, and then

In Win11 system, you can enable or disable Hyper-V enhanced session mode through commands. This article will introduce how to use commands to operate and help users better manage and control Hyper-V functions in the system. Hyper-V is a virtualization technology provided by Microsoft. It is built into Windows Server and Windows 10 and 11 (except Home Edition), allowing users to run virtual operating systems in Windows systems. Although virtual machines are isolated from the host operating system, they can still use the host's resources, such as sound cards and storage devices, through settings. One of the key settings is to enable Enhanced Session Mode. Enhanced session mode is Hyper

On Douyin, users can not only share their life details and talents, but also interact with other users. In this process, sometimes we need to send files to other users, such as pictures, videos, etc. So, how to send files to others on Douyin? 1. How to send files to others on Douyin? 1. Open Douyin and enter the chat interface where you want to send files. 2. Click the "+" sign in the chat interface and select "File". 3. In the file options, you can choose to send pictures, videos, audio and other files. After selecting the file you want to send, click "Send". 4. Wait for the other party to accept your file. Once the other party accepts it, the file will be transferred successfully. 2. How to delete files sent to others on Douyin? 1. Open Douyin and enter the text you sent.

How to reset tcp/ip protocol in win10? In fact, the method is very simple. Users can directly enter the command prompt, and then press the ctrl shift enter key combination to perform the operation, or directly execute the reset command to set it up. Let this site do the following. Let us carefully introduce to users how to reset the TCP/IP protocol stack in Windows 10. Method 1 to reset the tcp/ip protocol stack in Windows 10. Administrator permissions 1. We use the shortcut key win R to directly open the run window, then enter cmd and hold down the ctrl shift enter key combination. 2. Or we can directly search for command prompt in the start menu and right-click

QQ email: QQ number@qq.com, English QQ email: English or numbers@qq.com, foxmail email account: set up your own account@foxmail.com, mobile phone email account: mobile phone number@qq.com. Tutorial Applicable Model: iPhone13 System: IOS15.3 Version: QQ Mailbox 6.3.3 Analysis 1QQ mailbox has four formats, commonly used QQ mailbox: QQ number@qq.com, English QQ mailbox: English or numbers@qq.com, foxmail Email account: set up your own account@foxmail.com, mobile phone email account: mobile phone number@qq.com. Supplement: What is qq mailbox? 1 The earliest QQ mailbox was only between QQ users

1. Overview The sar command displays system usage reports through data collected from system activities. These reports are made up of different sections, each containing the type of data and when the data was collected. The default mode of the sar command displays the CPU usage at different time increments for various resources accessing the CPU (such as users, systems, I/O schedulers, etc.). Additionally, it displays the percentage of idle CPU for a given time period. The average value for each data point is listed at the bottom of the report. sar reports collected data every 10 minutes by default, but you can use various options to filter and adjust these reports. Similar to the uptime command, the sar command can also help you monitor the CPU load. Through sar, you can understand the occurrence of excessive load
