那要看你记录的信息内容。
一、单纯记录邮箱地址 ,一个字符串即可。
二、记录并验证邮箱,字符串数组,把地址里的用户名和域名分开来放,用于服务器查询。(当然用一个字符串保存,查询时再拆分也可)。
三、复合结构 ,比如注册的邮箱信息,包含账户,密码,真实姓名, *** 等等。需定义结构体来保存。
用C语言基本是做不出来的,要做工程量也极大,一切底层的都要从头做,你可以考虑用c++做,也不是一会儿就做的
你首先得懂JavaScript,去查看网站邮箱检测注册的原理程序,然后用C语言调用 *** 函数实现
基本框架就是这,需要其他功能自己添加吧
C语言实现简单的 *** TP发送邮件
#include windows.h
#include stdio.h
#include WinSock.h
#include iostream
using namespace std;
#pragma comment(lib, "ws2_32.lib")
struct Base64Date6
{
unsigned int d4:6;
unsigned int d3:6;
unsigned int d2:6;
unsigned int d1:6;
};
// 协议中加密部分使用的是base64 ***
char ConvertToBase64 (char c6);
void EncodeBase64 (char *dbuf, char *buf128, int len);
void SendMail (char *email,char *body);
int OpenSocket (struct sockaddr *addr);
int main()
{
char EmailTo[] = "hanyinlong@126.com";
char EmailContents[] = "From: \"lucy\"hanyinlong@126.com\r\n"
"To: \"dasiy\"hanyinlong@126.com\r\n"
"Subject: Hello\r\n\r\n"
"Hello World, Hello Email!";
SendMail(EmailTo, EmailContents);
return 0;
}
char ConvertToBase64(char uc)
{
if(uc 26)
{
return 'A' + uc;
}
if(uc 52)
{
return 'a' + (uc - 26);
}
if(uc 62)
{
return '0' + (uc - 52);
}
if(uc == 62)
{
return '+';
}
return '/';
}
// base64的实现
void EncodeBase64(char *dbuf, char *buf128, int len)
{
struct Base64Date6 *ddd = NULL;
int i = 0;
char buf[256] = {0};
char *tmp = NULL;
char cc = '\0';
memset(buf, 0, 256);
strcpy_s(buf, 256, buf128);
for(i = 1; i = len/3; i++)
{
tmp = buf + (i-1)*3;
cc = tmp[2];
tmp[2] = tmp[0];
tmp[0] = cc;
ddd = (struct Base64Date6 *)tmp;
dbuf[(i-1)*4+0] = ConvertToBase64((unsigned int)ddd-d1);
dbuf[(i-1)*4+1] = ConvertToBase64((unsigned int)ddd-d2);
dbuf[(i-1)*4+2] = ConvertToBase64((unsigned int)ddd-d3);
dbuf[(i-1)*4+3] = ConvertToBase64((unsigned int)ddd-d4);
}
if(len % 3 == 1)
{
tmp = buf + (i-1)*3;
cc = tmp[2];
tmp[2] = tmp[0];
tmp[0] = cc;
ddd = (struct Base64Date6 *)tmp;
dbuf[(i-1)*4+0] = ConvertToBase64((unsigned int)ddd-d1);
dbuf[(i-1)*4+1] = ConvertToBase64((unsigned int)ddd-d2);
dbuf[(i-1)*4+2] = '=';
dbuf[(i-1)*4+3] = '=';
}
if(len%3 == 2)
{
tmp = buf+(i-1)*3;
cc = tmp[2];
tmp[2] = tmp[0];
tmp[0] = cc;
ddd = (struct Base64Date6 *)tmp;
dbuf[(i-1)*4+0] = ConvertToBase64((unsigned int)ddd-d1);
dbuf[(i-1)*4+1] = ConvertToBase64((unsigned int)ddd-d2);
dbuf[(i-1)*4+2] = ConvertToBase64((unsigned int)ddd-d3);
dbuf[(i-1)*4+3] = '=';
}
return;
}
// 发送邮件
void SendMail(char *email, char *body)
{
int sockfd = {0};
char buf[1500] = {0};
char rbuf[1500] = {0};
char login[128] = {0};
char pass[128] = {0};
WSADATA WSAData;
struct sockaddr_in their_addr = {0};
WSAStartup(MAKEWORD(2, 2), WSAData);
memset(their_addr, 0, sizeof(their_addr));
their_addr.sin_family = AF_INET;
their_addr.sin_port = htons(25);
hostent* hptr = gethostbyname(" *** tp.126.com");
memcpy(their_addr.sin_addr.S_un.S_addr, hptr-h_addr_list[0], hptr-h_length);
printf("IP of *** pt.126.com is : %d:%d:%d:%d\n",
their_addr.sin_addr.S_un.S_un_b.s_b1,
their_addr.sin_addr.S_un.S_un_b.s_b2,
their_addr.sin_addr.S_un.S_un_b.s_b3,
their_addr.sin_addr.S_un.S_un_b.s_b4);
// 连接邮件服务器,如果连接后没有响应,则2 秒后重新连接
sockfd = OpenSocket((struct sockaddr *)their_addr);
memset(rbuf, 0, 1500);
while(recv(sockfd, rbuf, 1500, 0) == 0)
{
cout"reconnect..."endl;
Sleep(2);
sockfd = OpenSocket((struct sockaddr *)their_addr);
memset(rbuf, 0, 1500);
}
coutrbufendl;
// EHLO
memset(buf, 0, 1500);
sprintf_s(buf, 1500, "EHLO HYL-PC\r\n");
send(sockfd, buf, strlen(buf), 0);
memset(rbuf, 0, 1500);
recv(sockfd, rbuf, 1500, 0);
cout"EHLO REceive: "rbufendl;
// AUTH LOGIN
memset(buf, 0, 1500);
sprintf_s(buf, 1500, "AUTH LOGIN\r\n");
send(sockfd, buf, strlen(buf), 0);
memset(rbuf, 0, 1500);
recv(sockfd, rbuf, 1500, 0);
cout"Auth Login Receive: "rbufendl;
// USER
memset(buf, 0, 1500);
sprintf_s(buf, 1500, "hanyinlong@126.com");//你的邮箱账号
memset(login, 0, 128);
EncodeBase64(login, buf, strlen(buf));
sprintf_s(buf, 1500, "%s\r\n", login);
send(sockfd, buf, strlen(buf), 0);
cout"Base64 UserName: "bufendl;
memset(rbuf, 0, 1500);
recv(sockfd, rbuf, 1500, 0);
cout"User Login Receive: "rbufendl;
// PASSWORD
sprintf_s(buf, 1500, "XXXXXXXXXXXX");//你的邮箱密码
memset(pass, 0, 128);
EncodeBase64(pass, buf, strlen(buf));
sprintf_s(buf, 1500, "%s\r\n", pass);
send(sockfd, buf, strlen(buf), 0);
cout"Base64 Password: "bufendl;
memset(rbuf, 0, 1500);
recv(sockfd, rbuf, 1500, 0);
cout"Send Password Receive: "rbufendl;
// MAIL FROM
memset(buf, 0, 1500);
sprintf_s(buf, 1500, "MAIL FROM: hanyinlong@126.com\r\n");
send(sockfd, buf, strlen(buf), 0);
memset(rbuf, 0, 1500);
recv(sockfd, rbuf, 1500, 0);
cout"set Mail From Receive: "rbufendl;
// RCPT TO 之一个收件人
sprintf_s(buf, 1500, "RCPT TO:%s\r\n", email);
send(sockfd, buf, strlen(buf), 0);
memset(rbuf, 0, 1500);
recv(sockfd, rbuf, 1500, 0);
cout"Tell Sendto Receive: "rbufendl;
// DATA 准备开始发送邮件内容
sprintf_s(buf, 1500, "DATA\r\n");
send(sockfd, buf, strlen(buf), 0);
memset(rbuf, 0, 1500);
recv(sockfd, rbuf, 1500, 0);
cout"Send Mail Prepare Receive: "rbufendl;
// 发送邮件内容,\r\n.\r\n内容结束标记
sprintf_s(buf, 1500, "%s\r\n.\r\n", body);
send(sockfd, buf, strlen(buf), 0);
memset(rbuf, 0, 1500);
recv(sockfd, rbuf, 1500, 0);
cout"Send Mail Receive: "rbufendl;
// QUIT
sprintf_s(buf, 1500, "QUIT\r\n");
send(sockfd, buf, strlen(buf), 0);
memset(rbuf, 0, 1500);
recv(sockfd, rbuf, 1500, 0);
cout"Quit Receive: "rbufendl;
//清理工作
closesocket(sockfd);
WSACleanup();
return;
}
// 打开TCP Socket连接
int OpenSocket(struct sockaddr *addr)
{
int sockfd = 0;
sockfd=socket(PF_INET, SOCK_STREAM, 0);
if(sockfd 0)
{
cout"Open sockfd(TCP) error!"endl;
exit(-1);
}
if(connect(sockfd, addr, sizeof(struct sockaddr)) 0)
{
cout"Connect sockfd(TCP) error!"endl;
exit(-1);
}
return sockfd;
}
腾讯企业邮箱有哪些优势 腾讯企业邮箱的优势:1.微信直接收发邮件无需安装第三方APP,捆绑微信便可随时随地收发邮件,还能及时收到新邮件提醒。腾讯企业邮作为微信企业号的默认邮箱应用,邮箱通讯录已实现与企...
怎么知道邮箱号码是多少? 登录您的邮箱,在设置中查看您的邮箱号码。 如果您的邮箱是QQ邮箱,可以登录QQ客户端,在设置中查看您的邮箱号码。 如果您的邮箱是163邮箱,可以登录163邮箱客户端,在设置中...
急求黑客帝国1英文影评,100-200字左右 This is a story in the future, about the Earth's environment has been destroy...
网易邮箱可以发给QQ邮箱吗 演示机型:华为MateBookX 系统版本:win10 APP版本:网易邮箱4.15.8QQ邮箱6.2.1网易邮箱可以发给QQ邮箱。只要对方的邮箱地址是正确16...
怎么把邮件压缩到25mb以内 压缩软件。打开压缩软件,找到需要压缩的文件,选中后单击鼠标右键,选择添加到压缩文件,接着在弹出的窗口中点击立即压缩,然后等待文件自动压缩就可以了。邮件压缩减少邮箱的大小,...
山西的邮政编码是多少? 如果怕写错,太原市 通用030000 就可以了具体:霍县 031400 离石县 033000 兴县 035300山西 太原市 北典膳所 030001山西 太原市 并州北路...