if NMSMTP1.Connected then begin
        nmsmtp1.EncodeType := uuMime;
        nmsmtp1.PostMessage.FromAddress := EditUserId.Text;
        nmsmtp1.PostMessage.ToAddress.Text := EditReceiver.Text;
        nmsmtp1.PostMessage.Body.Text := Memo1.Lines.Text;
        nmsmtp1.PostMessage.Attachments.Text := ListBox1.Items.Text;
        nmsmtp1.PostMessage.Subject := EditSubject.Text;
        nmsmtp1.SendMail;
    end
    else
        StatusBar1.Panels[0].Text := '当前未与服务器连接';错误信息:
553 you are not authorized to send mail as <MAIL FROM;<cutecheng>>,
authentication is required.后来我找了个例子,加上下面几句:        nmsmtp1.Transaction('auth login');
        nmsmtp1.Transaction(strUserName);
        nmsmtp1.Transaction(strPassword);
还是出现同样的错误,怎么办啊?

解决方案 »

  1.   

    找到答案了,在源码空间搜索 SMTP
      

  2.   

    用delphi6.0 的indy 组建----〉indy smtp 结合 indy message 可以实现。
      

  3.   

    procedure TForm1.NMSMTP_myConnect(Sender: TObject);
    begin
          if nmsmtp_my.ReplyNumber = 250 then
    nmsmtp_my.Transaction('auth login');
    if nmsmtp_my.ReplyNumber = 334 then
    begin
    nmsmtp_my.Transaction(EncodeBase64('cww'));//用户名
    nmsmtp_my.Transaction(EncodeBase64('fha'));//密码
    end;
    showmessage(inttostr(nmsmtp_my.ReplyNumber));end;
    function EncodeBase64(Source:string):string; 
    var
    Times, LenSrc, i: Integer; 
    x1, x2, x3, x4: Char;
    xt: Byte; 
    begin 
    Result := ''; 
    LenSrc := Length(Source);
    if LenSrc mod 3 = 0 then 
    Times := LenSrc div 3 
    else 
    Times := LenSrc div 3 + 1;
    for i := 0 to Times - 1 do 
    begin 
    if LenSrc >= (3 + i * 3) then 
    begin
    x1 := BaseTable[(ord(Source[1 + i * 3]) shr 2)+1]; 
    xt := (ord(Source[1 + i * 3]) shl 4) and 48; 
    xt := xt or (ord(Source[2 + i * 3]) shr 4); 
    x2 := BaseTable[xt + 1];
    xt := (Ord(Source[2 + i * 3]) shl 2) and 60; 
    xt := xt or (Ord(Source[3 + i * 3]) shr 6); 
    x3 := BaseTable[xt + 1]; 
    xt := (ord(Source[3 + i * 3]) and 63);
    x4 := BaseTable[xt + 1]; 
    end 
    else if LenSrc >= (2 + i * 3) then
    begin
    x1 := BaseTable[(Ord(Source[1 + i * 3]) shr 2) + 1];
    xt := (Ord(Source[1 + i * 3]) shl 4) and 48;
    xt := xt or (Ord(Source[2 + i * 3]) shr 4);
    x2 := BaseTable[xt + 1];
    xt := (Ord(Source[2 + i * 3]) shl 2) and 60;
    x3 := BaseTable[xt + 1];
    x4 := '=';
    end else 
    begin
    x1 := BaseTable[(Ord(Source[1 + i * 3]) shr 2)+1];
    xt := (Ord(Source[1 + i * 3]) shl 4) and 48; 
    x2 := BaseTable[xt + 1];
    x3 := '='; 
    x4 := '=';
    end; 
    Result := Result + x1 + x2 + x3 + x4;
    end;
    end;