请各位高手指教!(100分)

  • 主题发起人 主题发起人 xda
  • 开始时间 开始时间
X

xda

Unregistered / Unconfirmed
GUEST, unregistred user!
请问Mail2000能实现SMTP认证吗?怎么实现?
 
你所说的mail2000是客户端吗?如果是,下面解答不算数。
_____________________
smtp.mail2000.com.tw
实现SMTP认证,是客户端(如outlook express, foxmail)的事.

 
SMTP认证?协议要认证?
 
To ty123:是客户端。我用Mail2000控件做电子邮件客户端软件。
 
要用到CodeBase64编码和解码,用tnmsmtp控件的Transaction函数和replynumber来完成。
程序中完全能够实现。
 
To milan:用Mail2000或SakMail控件能实现吗?
 
Mail2000没 indy 好用吧?

http://www.delphibbs.com/delphibbs/dispq.asp?lid=2198132
 
To shaga:Indy存在一些问题,如发送带附件的HTML格式的邮件存在问题。欢迎到http://www.delphibbs.com/delphibbs/dispq.asp?lid=2182832指教。
 
你把这个问题就直接写在题目上多好,看的人会更我,且像我这样岩痴的人就不用进来浪费
时间.
 
用FASTNET中的控件吧,下面是收发需要SMTP认证的邮件例子
****************************************************
unit email;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, SUIMainMenu, ExtCtrls, SUIForm, Buttons, ComCtrls,
ToolWin, StdCtrls, SUIListView, SUITreeView, SUIImagePanel, SUIPopupMenu,
ImgList, SUIButton, SUIMemo, SUIListBox, SUIEdit, Psock, NMsmtp, NMpop3,
ShellCtrls,shellapi, DB, ADODB, DosMove;

type
Temailform = class(TForm)
suiForm1: TsuiForm;
ImageList1: TImageList;
suiListView1: TsuiListView;
suiImagePanel1: TsuiImagePanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
suiEdit1: TsuiEdit;
suiEdit2: TsuiEdit;
suiListBox1: TsuiListBox;
suiMemo1: TsuiMemo;
suiButton6: TsuiButton;
suiButton7: TsuiButton;
suiButton1: TsuiButton;
suiButton2: TsuiButton;
OpenDialog1: TOpenDialog;
suiButton3: TsuiButton;
ShellListView1: TShellListView;
ADOQuery1: TADOQuery;
Memo1: TMemo;
suiButton4: TsuiButton;
suiButton5: TsuiButton;
suiButton8: TsuiButton;
Timer1: TTimer;
suiButton9: TsuiButton;
ADOQuery2: TADOQuery;
suiPopupMenu1: TsuiPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
suiButton10: TsuiButton;
DosMove1: TDosMove;
suiButton11: TsuiButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure suiButton1Click(Sender: TObject);
procedure suiButton2Click(Sender: TObject);
procedure suiButton6Click(Sender: TObject);
procedure suiButton3Click(Sender: TObject);
procedure NMPOP31List(Msg, Size: Integer);
procedure suiButton4Click(Sender: TObject);
procedure suiListView1DblClick(Sender: TObject);
procedure suiListView1SelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
procedure suiButton5Click(Sender: TObject);
procedure suiButton8Click(Sender: TObject);
procedure suiListBox1DblClick(Sender: TObject);
procedure suiListBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure suiButton9Click(Sender: TObject);
procedure N6Click(Sender: TObject);
procedure suiButton10Click(Sender: TObject);
procedure yixiaobing(sender:tobject);
procedure suiButton11Click(Sender: TObject);
private
{ Private declarations }

public
{ Public declarations }
end;

var
emailform: Temailform;
emailid:string;
emailitem:tlistitem;
exefile:string;
yxb_chenggong:string;
implementation

uses main, login, reg, thread2, thread4, unit_qipao, dialog, jindu;

{$R *.dfm}


function EncodeBASE64(Encoded: TMemoryStream ; Decoded: TMemoryStream): Integer;
const
_Code64: String[64] =('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/');
var
I: LongInt;
B: array[0..2279] of Byte;
J, K, L, M, Quads: Integer;
Stream: string[76];
EncLine: String;
begin
Encoded.Clear;
Stream := '';
Quads := 0;
{为提高效率,每2280字节流为一组进行编码}
J := Decoded.Size div 2280;
Decoded.Position := 0;
{对前J*2280个字节流进行编码}
for I := 1 to J do
begin
Decoded.Read(B, 2280);
for M := 0 to 39 do
begin
for K := 0 to 18 do
begin
L:= 57*M + 3*K;
Stream[Quads+1] := _Code64[(B[L] div 4)+1];
Stream[Quads+2] := _Code64[(B[L] mod 4)*16 + (B[L+1] div 16)+1];
Stream[Quads+3] := _Code64[(B[L+1] mod 16)*4 + (B[L+2] div 64)+1];
Stream[Quads+4] := _Code64[B[L+2] mod 64+1];
Inc(Quads, 4);
if Quads = 76 then
begin
Stream[0] := #76;
EncLine := Stream+#13#10;
Encoded.Write(EncLine[1], Length(EncLine));
Quads := 0;
end;
end;
end;
end;

{对以2280为模的余数字节流进行编码}
J := (Decoded.Size mod 2280) div 3;
for I := 1 to J do
begin
Decoded.Read(B, 3);
Stream[Quads+1] := _Code64[(B[0] div 4)+1];
Stream[Quads+2] := _Code64[(B[0] mod 4)*16 + (B[1] div 16)+1];
Stream[Quads+3] := _Code64[(B[1] mod 16)*4 + (B[2] div 64)+1];
Stream[Quads+4] := _Code64[B[2] mod 64+1];
Inc(Quads, 4);
{每行76个字符}
if Quads = 76 then
begin
Stream[0] := #76;
EncLine := Stream+#13#10;
Encoded.Write(EncLine[1], Length(EncLine));
Quads := 0;
end;
end;
{“=”补位}
if (Decoded.Size mod 3) = 2 then
begin
Decoded.Read(B, 2);
Stream[Quads+1] := _Code64[(B[0] div 4)+1];
Stream[Quads+2] := _Code64[(B[0] mod 4)*16 + (B[1] div 16)+1];
Stream[Quads+3] := _Code64[(B[1] mod 16)*4 + 1];
Stream[Quads+4] := '=';
Inc(Quads, 4);
end;

if (Decoded.Size mod 3) = 1 then
begin
Decoded.Read(B, 1);
Stream[Quads+1] := _Code64[(B[0] div 4)+1];
Stream[Quads+2] := _Code64[(B[0] mod 4)*16 + 1];
Stream[Quads+3] := '=';
Stream[Quads+4] := '=';
Inc(Quads, 4);
end;

Stream[0] := Chr(Quads);
if Quads > 0 then
begin
EncLine := Stream+#13#10;
Encoded.Write(EncLine[1], Length(EncLine));
end;

Result := Encoded.Size;
end;


function EncodeString(Decoded:string):String;
var
mmTemp,mmDecoded:TMemoryStream;
strTemp:TStrings;
begin
mmTemp := TMemoryStream.Create;
mmDecoded:=TMemoryStream.Create;
strTemp:=TStringList.Create;
strTemp.Add(Decoded);
strTemp.SaveToStream(mmTemp);
mmTemp.Position := 0;
{剔除mmTemp从strTemp中带来的字符#13#10}
mmDecoded.CopyFrom(mmTemp,mmTemp.Size-2);
{对mmDecoded进行Base64编码,由mmTemp返回编码后的结果}
EncodeBASE64(mmTemp,mmDecoded);
{获得Base64编码后的字符串}
mmTemp.Position:=0;
strTemp.LoadFromStream(mmTemp);
{返回结果必须从strTemp[0]中获得,如果使用strTemp.Text会
带来不必要的字符#13#10}
Result:=strTemp[0];
end;


procedure Temailform.FormCreate(Sender: TObject);
var
listitem:Tlistitem;
yxbstr1,yxbstr2:string;
yxbint1,yxbint2:integer;
begin
jiance:='true';
suiform1.Width:=636;
suiform1.Height:=400;
emailform.suiForm1.UIStyle:=jiemian;
if not DirectoryExists(extractfilepath(application.exename)+'fastoa') then
begin
CreateDirectory(pchar(extractfilepath(application.exename)+'fastoa'),0);
end;
ShellListView1.Root:=extractfilepath(application.ExeName)+'fastoa';
shelllistview1.Refresh;
adoquery1.ConnectionString:=adostr;
adoquery1.SQL.Text:='select * from recivemail';
adoquery1.Active:=true;

emailform.adoquery1.close;
emailform.adoquery1.SQL.Text:='select * from recivemail order by 接收日期 desc';
emailform.ADOQuery1.Open;

adoquery2.ConnectionString:=adostr;
adoquery2.SQL.Text:='select * from addresslist';
adoquery2.Active:=true;

emailform.adoquery2.close;
emailform.adoquery2.SQL.Text:='select * from addresslist ';
emailform.ADOQuery2.Open;

emailform.Refresh;


while not emailform.ADOQuery1.Eof do
begin

with emailform.suiListView1 do
begin
ListItem :=Items.Add;
if emailform.ADOQuery1['是否有附件']='有' then
listitem.ImageIndex:=2
else
listitem.ImageIndex:=0;

ListItem.Caption := emailform.ADOQuery1['邮件编号'];
ListItem.SubItems.Add(emailform.ADOQuery1['是否阅读']);
yxbstr1:=emailform.ADOQuery1['发件人邮箱'];
if pos('<',yxbstr1)>0 then yxbint1:=pos('<',yxbstr1);
if pos('>',yxbstr1)>0 then yxbint2:=pos('>',yxbstr1);
yxbstr2:=copy(yxbstr1,yxbint1+1,yxbint2-yxbint1-1);
with emailform.ADOQuery2 do
begin
close;
sql.Text:='select * from addresslist where Email='''+yxbstr2+''' ';
open;
if recordcount>0 then
ListItem.SubItems.Add(emailform.ADOQuery2['姓名'])
else
ListItem.SubItems.Add(emailform.ADOQuery1['发件人邮箱']);
end;


ListItem.SubItems.Add(emailform.ADOQuery1['主题']);
ListItem.SubItems.Add(emailform.ADOQuery1['接收日期']);
ListItem.SubItems.Add(emailform.ADOQuery1['邮件大小']);
end;
emailform.ADOQuery1.Next;
end;
end;

procedure Temailform.FormDestroy(Sender: TObject);
begin
emailform:=nil;
end;

procedure Temailform.FormClose(Sender: TObject; var Action: TCloseAction);
begin
mainform.Enabled:=true;
mainform.Timer1.Enabled:=true;
jiance:='false';
action:=cafree;
end;

procedure Temailform.suiButton1Click(Sender: TObject);
begin
if myemail='' then
begin
peedy.Play('confused');
peedy.Play('lookright');
peedy.Play('gestureright');
peedy.Speak('请在系统设置中注册个人信息!',extractfilepath(application.ExeName)+'wav/main/1.wav');
peedy.Play('RestPose');
exit;
end;
exefile:='长';
suiedit1.Clear;
suiedit2.Clear;
suilistbox1.Clear;
suimemo1.Clear;
suiListView1.Visible:=false;
ShellListView1.Visible:=false;
suiImagePanel1.Visible:=true;
label1.Caption:='收件人:';
end;

procedure Temailform.suiButton2Click(Sender: TObject);
var
mythread:yixiaobingthread2;
i:integer;
begin
if myemail='' then
begin
peedy.Play('confused');
peedy.Play('lookright');
peedy.Play('gestureright');
peedy.Speak('请在系统设置中注册个人信息!',extractfilepath(application.ExeName)+'wav/main/2.wav');
peedy.Play('RestPose');
suiedit1.SetFocus;
exit;
end;
yxb_jindu:='发送';
try
if trim(suiedit1.Text)='' then
begin
peedy.Play('confused');
peedy.Play('lookright');
peedy.Play('gestureright');
peedy.Speak('收件人不能为空!',extractfilepath(application.ExeName)+'wav/main/3.wav');
peedy.Play('RestPose');
suiedit1.SetFocus;
exit;
end;

if (pos('@',suiedit1.Text)=0) or (pos('.',suiedit1.Text)=0) then
begin
peedy.Play('confused');
peedy.Play('lookright');
peedy.Play('gestureright');
peedy.Speak('收件人Email地址格式不正确!',extractfilepath(application.ExeName)+'wav/main/4.wav');
peedy.Play('RestPose');
suiedit1.SetFocus;
exit;
end;

if trim(suiedit2.Text)='' then
begin
peedy.Play('confused');
peedy.Play('lookright');
peedy.Play('gestureright');
peedy.Speak('主题不能为空!',extractfilepath(application.ExeName)+'wav/main/5.wav');
peedy.Play('RestPose');
suiedit2.SetFocus;
exit;
end;

if trim(suimemo1.Text)='' then
begin
peedy.Play('confused');
peedy.Play('lookright');
peedy.Play('gestureright');
peedy.Speak('内容不能为空!',extractfilepath(application.ExeName)+'wav/main/6.wav');
peedy.Play('RestPose');
suimemo1.SetFocus;
exit;
end;
suibutton2.Enabled:=false;
if exefile='短' then
begin
for i:=0 to suilistbox1.Items.Count-1 do
begin
suilistbox1.Items:=extractfilepath(application.ExeName)+'fastoa/'+suilistbox1.Items;
end;
end;
yxb_jindu:='发送';
if assigned(jinduform) then
begin
peedy.Play('confused');
peedy.Play('lookright');
peedy.Play('gestureright');
peedy.Speak('FASTOA正在检测邮件服务器!请重试!',extractfilepath(application.ExeName)+'wav/main/7.wav');
peedy.Play('RestPose');
exit;
end;
Application.CreateForm(Tjinduform, jinduform);
jinduform.Show;
mythread:=yixiaobingthread2.Create(false);
peedy.Play('write');
exefile:='长';
except
if assigned(jinduform) then jinduform.Close;
mainform.Timer3.Enabled:=true;
peedy.Show(0);
peedy.Play('confused');
peedy.Speak('邮件发送失败!',extractfilepath(application.ExeName)+'wav/main/8.wav');
peedy.Play('RestPose');
end;
end;

procedure Temailform.suiButton6Click(Sender: TObject);
begin
application.CreateForm(tfastoadialog,fastoadialog);
fastoadialog.ShowModal;
if (yxbfile<>'') and (yxbfilepath<>'') then
suiListBox1.Items.Add(yxbfilepath);
yxbfile:='';
yxbfilepath:='';
end;


procedure Temailform.suiButton3Click(Sender: TObject);
var
i,j:integer;
s1,s2,s3,s4,s5:string;
ListItem:tlistitem;
mythread:yixiaobingthread4;
begin
if myemail='' then
begin
peedy.Play('confused');
peedy.Play('lookright');
peedy.Play('gestureright');
peedy.Speak('请在系统设置中注册个人信息!',extractfilepath(application.ExeName)+'wav/main/9.wav');
peedy.Play('RestPose');
exit;
end;
peedy.Play('read');
ShellListView1.Visible:=false;
suiImagePanel1.Visible:=false;
suilistview1.Clear;
jiance:='true';
yxb_jindu:='接收';
if assigned(jinduform) then
begin
peedy.Play('confused');
peedy.Play('lookright');
peedy.Play('gestureright');
peedy.Speak('FASTOA正在检测邮件服务器!请重试!',extractfilepath(application.ExeName)+'wav/main/10.wav');
peedy.Play('RestPose');
exit;
end;
Application.CreateForm(Tjinduform, jinduform);
jinduform.Show;
mythread:=yixiaobingthread4.Create(false);
{suiListView1.Visible:=true;
ShellListView1.Visible:=true;
mainform.NMPOP31.AttachFilePath := extractfilepath(application.exename)+'fastoa';
//NMPOP31.DeleteOnRead := true;
mainform.NMPOP31.ReportLevel := Status_Basic;
mainform.NMPOP31.Host := smtp;
mainform.NMPOP31.Port := 110;
mainform.NMPOP31.UserID := userid;
mainform.NMPOP31.Password := password;
if not mainform.nmpop31.Connected then
mainform.NMPOP31.Connect;
mainform.NMPOP31.List;

if yxb_num>0 then
begin
for i:=1 to yxb_num do
begin
s1:='';
s2:='';
s3:='';
s4:='';
s5:='';
s4:='未';
mainform.NMPOP31.GetMailMessage(i);
s1:= mainform.NMPOP31.MailMessage.From; //发件人
s2:= mainform.NMPOP31.MailMessage.Subject;//主题
memo1.Lines.Clear;
memo1.Lines.Assign(mainform.NMPOP31.MailMessage.Body);//内容
If mainform.NMPOP31.MailMessage.Attachments.Text <> '' then
begin
s3:='有';
for j:=1 to mainform.nmpop31.MailMessage.Attachments.Count do
begin
if j=mainform.nmpop31.MailMessage.Attachments.Count then
begin
s5:=s5+mainform.nmpop31.MailMessage.Attachments.Text;
break;
end;
s5:=s5+mainform.nmpop31.MailMessage.Attachments.Text+',';
end;

end;

adoquery1.Append;
adoquery1['是否有附件']:=s3;
adoquery1['是否阅读']:=s4;
adoquery1['接收日期']:=date;
adoquery1['发件人邮箱']:=s1;
adoquery1['收件人邮箱']:=myemail;
adoquery1['主题']:=s2;
adoquery1['内容']:=memo1.Text;
adoquery1['邮件大小']:=yxb_size;
adoquery1['附件']:=s5;
adoquery1.Post;

with suiListView1 do
begin
ListItem :=Items.Add;
if s3='有' then
suilistview1.Columns[0].ImageIndex:=2
else
suilistview1.Columns[0].ImageIndex:=0;

if s4='未' then
suilistview1.Columns[1].ImageIndex:=3
else
suilistview1.Columns[1].ImageIndex:=4;

ListItem.Caption := s3;
ListItem.SubItems.Add(s4);
ListItem.SubItems.Add(s1);
ListItem.SubItems.Add(s2);
ListItem.SubItems.Add(datetostr(date));
ListItem.SubItems.Add(inttostr(yxb_size));
end;

end;

end;}
end;

procedure Temailform.NMPOP31List(Msg, Size: Integer);
begin
yxb_num:=msg;
yxb_size:=size;
end;

procedure Temailform.suiButton4Click(Sender: TObject);
begin
peedy.Play('read');
suilistview1.Visible:=true;
suiimagepanel1.Visible:=false;
ShellListView1.Visible:=false;
end;

procedure Temailform.suiListView1DblClick(Sender: TObject);
var
ListItem:tlistitem;
str:string;
yxbstr1,yxbstr2:string;
yxbint1,yxbint2:integer;
begin
if suilistview1.Selected=nil then
begin
peedy.Play('confused');
peedy.Play('lookright');
peedy.Play('gestureright');
peedy.Speak('请在邮件列表中选中一个项目!',extractfilepath(application.ExeName)+'wav/main/11.wav');
peedy.Play('RestPose');
exit;
end;
suiImagePanel1.Visible:=true;
ShellListView1.Visible:=true;
with suiListView1 do
begin
listitem:=suilistview1.Selected;
str:=listitem.Caption;
listitem.SubItems[0]:='已';
adoquery1.Close;
adoquery1.SQL.Text:='select * from recivemail where 邮件编号=convert(integer,'''+str+''') ';
adoquery1.Open;
adoquery1.Edit;
adoquery1['是否阅读']:='已';
adoquery1.Post;
str:=adoquery1['附件'];
with adoquery2 do
begin
close;
sql.Text:='select * from addresslist where 姓名='''+listitem.SubItems[1]+'''';
open;
if recordcount>0 then
suiedit1.Text:=adoquery2['Email']
else
begin
yxbstr1:=adoquery1['发件人邮箱'];
if pos('<',yxbstr1)>0 then yxbint1:=pos('<',yxbstr1);
if pos('>',yxbstr1)>0 then yxbint2:=pos('>',yxbstr1);
yxbstr2:=copy(yxbstr1,yxbint1+1,yxbint2-yxbint1-1);
suiedit1.Text:=yxbstr2;
end;
end;

suiedit2.Text:=trim(listitem.SubItems[2]);
suimemo1.Text:=adoquery1['附件'];
suilistbox1.Items.Assign(suimemo1.Lines);
exefile:='短';
suimemo1.Clear;
suimemo1.Text:=trim(adoquery1['内容']);
end;
label1.Caption:='发件人:';
suilistview1.Visible:=false;
end;

procedure Temailform.suiListView1SelectItem(Sender: TObject;
Item: TListItem; Selected: Boolean);
begin
emailid:=item.Caption;
emailitem:=item;
end;

procedure Temailform.suiButton5Click(Sender: TObject);
begin
peedy.MoveTo(screen.Width div 2 ,screen.Height div 2 +40,1);
sleep(2000);
application.CreateForm(tfrm_qipao,frm_qipao);
frm_qipao.ShowModal;
if (shanchu='是') and (emailid<>'') then
begin
adoquery1.Close;
adoquery1.SQL.Text:='delete from recivemail where 邮件编号=convert(integer,'''+emailid+''') ';
adoquery1.ExecSQL;
emailitem.Delete;
end;
shanchu:='否';
//
mainform.adoquery1.Close;
mainform.adoquery1.SQL.Text:='select * from recivemail where 是否阅读=''未'' and 收件人邮箱='''+myemail+''' ';
mainform.adoquery1.Open;
if mainform.ADOQuery1.RecordCount>0 then
begin
mainform.label7.Cursor:=crHandPoint;
mainform.label7.Font.Color:=clBlue;
tishi:='今天有'+inttostr(mainform.ADOQuery1.RecordCount)+'封新邮件!'+#13;
end
else
begin
mainform.label7.Cursor:=crDefault;
mainform.label7.Font.Color:=clBlack;
end;
mainform.label7.Caption:=inttostr(mainform.adoquery1.RecordCount);
mainform.label7.Refresh;
//
end;

procedure Temailform.suiButton8Click(Sender: TObject);
begin
suiListView1.Visible:=false;
suiImagePanel1.Visible:=false;
ShellListView1.Visible:=true;
end;

procedure Temailform.suiListBox1DblClick(Sender: TObject);
var
mypath:string;
begin
if suilistbox1.ItemIndex<0 then exit;
if exefile='短' then
begin
mypath:=extractfilepath(application.ExeName)+'fastoa/'+suilistbox1.items[suilistbox1.itemindex] ;
shellexecute(handle,'open',pchar(mypath),nil,nil,sw_normal);
end;
if exefile='长' then
begin
shellexecute(handle,'open',pchar(suilistbox1.items[suilistbox1.itemindex]),nil,nil,sw_normal);
end;
end;

procedure Temailform.suiListBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if suilistbox1.ItemIndex<0 then exit;
if key= 46 then
suiListBox1.Items.Delete(suiListBox1.ItemIndex);
suilistbox1.ItemIndex:=suilistbox1.ItemIndex+1;
end;

procedure Temailform.suiButton9Click(Sender: TObject);
var
i:integer;
begin
peedy.MoveTo(screen.Width div 2 ,screen.Height div 2 +40,1);
sleep(2000);
application.CreateForm(tfrm_qipao,frm_qipao);
frm_qipao.ShowModal;
if shanchu='是' then
begin
suilistview1.Items.Clear;
adoquery1.Close;
adoquery1.SQL.Text:='delete from recivemail';
adoquery1.ExecSQL;
peedy.Play('congratulate');
peedy.Speak('邮件删除成功!',extractfilepath(application.ExeName)+'wav/main/12.wav');
peedy.Play('RestPose');
mainform.label7.Cursor:=crDefault;
mainform.label7.Font.Color:=clBlack;
mainform.label7.Caption:='0';
mainform.label7.Refresh;
end;
shanchu:='否';
end;

procedure Temailform.N6Click(Sender: TObject);
begin
suilistview1.Items.Clear;
end;



procedure Temailform.suiButton10Click(Sender: TObject);
begin
mainform.WindowState:=wsMaximized;
close;
end;

procedure Temailform.yixiaobing(sender:tobject);
begin
if yxb_chenggong='成功' then
begin
peedy.Play('congratulate');
peedy.Speak('邮件发送成功!',extractfilepath(application.ExeName)+'wav/main/13.wav');
peedy.Play('RestPose');
yxb_chenggong:='';
emailform.suiButton2.Enabled:=true;
exit;
end;
if yxb_chenggong='失败' then
begin
peedy.Play('congratulate');
peedy.Speak('邮件发送失败!',extractfilepath(application.ExeName)+'wav/main/14.wav');
peedy.Play('RestPose');
yxb_chenggong:='';
emailform.suiButton2.Enabled:=true;
exit;
end;
end;

procedure Temailform.suiButton11Click(Sender: TObject);
var
s:tstringlist;
str:string;
begin
try
s:=tstringlist.Create;
s.AddStrings(suimemo1.Lines);
str:=extractfilepath(application.ExeName)+'内容.htm';
s.SaveToFile(str);
shellexecute(handle,'open',pchar(str),nil,nil,SW_MAXIMIZE);
emailform.WindowState:=wsMinimized;
mainform.WindowState:=wsMinimized;
finally
s.Free;
end;
end;

end.
 
或者直接看这个。在NMSMTP1控件的NMSMTP1Connect事件中这样写就行了。
******************************************************************
procedure Tmainform.NMSMTP1Connect(Sender: TObject);
function EncodeBASE64(Encoded: TMemoryStream ; Decoded: TMemoryStream): Integer;
const
_Code64: String[64] =('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/');
var
I: LongInt;
B: array[0..2279] of Byte;
J, K, L, M, Quads: Integer;
Stream: string[76];
EncLine: String;
begin
Encoded.Clear;
Stream := '';
Quads := 0;
{为提高效率,每2280字节流为一组进行编码}
J := Decoded.Size div 2280;
Decoded.Position := 0;
{对前J*2280个字节流进行编码}
for I := 1 to J do
begin
Decoded.Read(B, 2280);
for M := 0 to 39 do
begin
for K := 0 to 18 do
begin
L:= 57*M + 3*K;
Stream[Quads+1] := _Code64[(B[L] div 4)+1];
Stream[Quads+2] := _Code64[(B[L] mod 4)*16 + (B[L+1] div 16)+1];
Stream[Quads+3] := _Code64[(B[L+1] mod 16)*4 + (B[L+2] div 64)+1];
Stream[Quads+4] := _Code64[B[L+2] mod 64+1];
Inc(Quads, 4);
if Quads = 76 then
begin
Stream[0] := #76;
EncLine := Stream+#13#10;
Encoded.Write(EncLine[1], Length(EncLine));
Quads := 0;
end;
end;
end;
end;

{对以2280为模的余数字节流进行编码}
J := (Decoded.Size mod 2280) div 3;
for I := 1 to J do
begin
Decoded.Read(B, 3);
Stream[Quads+1] := _Code64[(B[0] div 4)+1];
Stream[Quads+2] := _Code64[(B[0] mod 4)*16 + (B[1] div 16)+1];
Stream[Quads+3] := _Code64[(B[1] mod 16)*4 + (B[2] div 64)+1];
Stream[Quads+4] := _Code64[B[2] mod 64+1];
Inc(Quads, 4);
{每行76个字符}
if Quads = 76 then
begin
Stream[0] := #76;
EncLine := Stream+#13#10;
Encoded.Write(EncLine[1], Length(EncLine));
Quads := 0;
end;
end;
{“=”补位}
if (Decoded.Size mod 3) = 2 then
begin
Decoded.Read(B, 2);
Stream[Quads+1] := _Code64[(B[0] div 4)+1];
Stream[Quads+2] := _Code64[(B[0] mod 4)*16 + (B[1] div 16)+1];
Stream[Quads+3] := _Code64[(B[1] mod 16)*4 + 1];
Stream[Quads+4] := '=';
Inc(Quads, 4);
end;

if (Decoded.Size mod 3) = 1 then
begin
Decoded.Read(B, 1);
Stream[Quads+1] := _Code64[(B[0] div 4)+1];
Stream[Quads+2] := _Code64[(B[0] mod 4)*16 + 1];
Stream[Quads+3] := '=';
Stream[Quads+4] := '=';
Inc(Quads, 4);
end;

Stream[0] := Chr(Quads);
if Quads > 0 then
begin
EncLine := Stream+#13#10;
Encoded.Write(EncLine[1], Length(EncLine));
end;

Result := Encoded.Size;
end;


function EncodeString(Decoded:string):String;
var
mmTemp,mmDecoded:TMemoryStream;
strTemp:TStrings;
begin
mmTemp := TMemoryStream.Create;
mmDecoded:=TMemoryStream.Create;
strTemp:=TStringList.Create;
strTemp.Add(Decoded);
strTemp.SaveToStream(mmTemp);
mmTemp.Position := 0;
{剔除mmTemp从strTemp中带来的字符#13#10}
mmDecoded.CopyFrom(mmTemp,mmTemp.Size-2);
{对mmDecoded进行Base64编码,由mmTemp返回编码后的结果}
EncodeBASE64(mmTemp,mmDecoded);
{获得Base64编码后的字符串}
mmTemp.Position:=0;
strTemp.LoadFromStream(mmTemp);
{返回结果必须从strTemp[0]中获得,如果使用strTemp.Text会
带来不必要的字符#13#10}
Result:=strTemp[0];
end;
var
strUserName, strPassword: String;
begin
strUserName := EncodeString(userid);//CoolSlob是服务器的帐号
strPassword := EncodeString(password);//Password是密码
nmsmtp1.Transaction('EHLO') ;
nmsmtp1.Transaction('AUTH LOGIN');
nmsmtp1.Transaction(strUserName);
nmsmtp1.Transaction(strPassword);

end;
 
humanc2d4大侠,Mail2000有Transaction的对应方法吗?SakMail也可。
 
刚才我掉线了。
mail2000我以前用过,好象也可以对需要SMTP认证的邮件进行收发处理。
而且mail2000是我们中国人自己开发的邮件控件。本来也想用但我不太喜欢
用第三方控件。我改用DELPHI自己的FASTNET中的控件。至于SAKMAIL我没有
用过,不太清楚。不知楼主还有什么疑问!
 
Mail2000实现SMTP认证的具体方法,在GOOGLE上搜索一下。
 
问题没有解决,先结贴。我准备用两种控件配合使用,各位大侠认为怎样?请继续指教。
 
后退
顶部