有没有人做过发邮件带附件的,用什么控件最好,需要登录SMTP的?(100分)

  • 主题发起人 socool_100
  • 开始时间
S

socool_100

Unregistered / Unconfirmed
GUEST, unregistred user!
做过发邮件的吗?说说做法吧,烦死我了。
 
indy的demo
 
To:idsmtp,影 子
indy,它的demo好象没有人证的吧?我发的是www.163.com的,是需要人证的,如何做?
 
indy的例子是带认证的,C:/Program Files/Borland/Delphi6/Demos/Indy/MailClient
在D7中竟然没有indy的例子.
 

163.com的邮箱是不能自己发给自己的(我的就是那样)。
但它的组件是可以支持认证的。看看帮助吧。
 
To:All
我看了,它的例子是有人证部分,不知为什么发不了?我用的就是Delphi6啊。
 
错误是这样的:
553 You are not authorized to send mail as <Mail from:<socool_100@163.com>>,
authentication is required.
所以,证明认证没有通过,不知例子是怎么搞的?
 
就是认证没有通过了.
给你作了个例子:http://www.tommstudio.com/testmail.rar
你下载看看.
 
To:www
大哥连不上啊,不过还是要谢谢你了!发的我EMail: socool_100@163.com吧!
 
smtp带验证的

unit UnitSmtpLogin;

interface

uses NMSMTP,classes,Sysutils;

type
EIdException = class(Exception);
TIdCardinalBytes = record
case Integer of
0: (
Byte1: Byte;
Byte2: Byte;
Byte3: Byte;
Byte4: Byte;);
1: (Whole: Cardinal);
end;

function login(smtp:TNMSMTP;user,password:string):boolean;


var
//MIME:
CodingTable: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
//UUE: CodingTable: string = '`!"#$%&amp;''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[/]^_';
//XXE: CodingTable: string = '+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';

//MIME:
FillChar: char = '=';
//UUE: CodingTable[1] or '~'
//XXE: CodingTable[1] or '~'

implementation

procedure EncodeUnit(const AIn1, AIn2, AIn3: Byte; var VOut: Cardinal);
var
LUnit: TIdCardinalBytes;
begin
LUnit.Byte1 := Ord(CodingTable[((AIn1 SHR 2) and 63) + 1]);
LUnit.Byte2 := Ord(CodingTable[(((AIn1 SHL 4) or (AIn2 SHR 4)) and 63) + 1]);
LUnit.Byte3 := Ord(CodingTable[(((AIn2 SHL 2) or (AIn3 SHR 6)) and 63) + 1]);
LUnit.Byte4 := Ord(CodingTable[(Ord(AIn3) and 63) + 1]);
VOut := LUnit.Whole;
end;

function Encode2(ASrcStream: TStream; const ABytes: integer = MaxInt): string;
var
LIn1, LIn2, LIn3: Byte;
LSize: integer;
LStartPos: integer;
LUnit: TIdCardinalBytes;
begin
//TODO: Make this more efficient. Profile it to test, but maybe make single calls to ReadBuffer
//then pull from memory
if (ABytes <> MaxInt) and ((ABytes mod 3) > 0) then begin
raise EIdException.Create('Uneven size in Encode.');
end;
Result := '';
LStartPos := ASrcStream.Position;
while (ASrcStream.Position < ASrcStream.Size) and (ASrcStream.Position - LStartPos < ABytes)
do begin
ASrcStream.ReadBuffer(LIn1, 1);
if ASrcStream.Position < ASrcStream.Size then begin
ASrcStream.ReadBuffer(LIn2, 1);
if ASrcStream.Position < ASrcStream.Size then begin
ASrcStream.ReadBuffer(LIn3, 1);
LSize := 3;
end else begin
LIn3 := 0;
LSize := 2;
end;
end else begin
LIn2 := 0;
LSize := 1;
end;
EncodeUnit(LIn1, LIn2, LIn3, LUnit.Whole);
Result := Result + Chr(LUnit.Byte1) + Chr(LUnit.Byte2) + Chr(LUnit.Byte3) + Chr(LUnit.Byte4);
if LSize < 3 then begin
Result[Length(Result)] := FillChar;
if LSize = 1 then begin
Result[Length(Result) - 1] := FillChar;
end;
end;
end;
end;

function Encode(const ASrc: string): string;
var
LSrcStream: TStringStream;
begin
LSrcStream := TStringStream.Create(ASrc); try
Result := Encode2(LSrcStream);
finally FreeAndNil(LSrcStream); end;
end;

function login(smtp:TNMSMTP;user,password:string):boolean;
const crlf = #13#10;
var
s:string;
begin
result:=false;
try
s:='auth LOGIN'+crlf;
smtp.SendBuffer(pchar(s),length(s));
s:=smtp.ReadLn;
if copy(s,1,3)<>'334' then exit; //Fail

s:=Encode(user)+crlf;
smtp.SendBuffer(pchar(s),length(s));
s:=copy(smtp.ReadLn,1,3);
if (s<>'334')and(s<>'235') then exit; //Fail

s:=Encode(password)+crlf;
smtp.SendBuffer(pchar(s),length(s));
s:=copy(smtp.ReadLn,1,3);
if (s<>'235') then exit; //Fail
result:=true;
except
end;
end;

end.
 
兄弟,帮你提一下

知道我是谁吗?
 
知道了兄弟上来帮忙,哎!
 
已解决谢谢所有的关心这个问题的兄弟!
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
958
SUNSTONE的Delphi笔记
S
D
回复
0
查看
961
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
顶部