Indy发送邮件被kbas退掉

用indy开发了发送邮件程序,通过126,sina等发送邮件可以发送出去,而通过tom,163则被退回,显示被

kbas系统退回.后来通过观察Foxmail的通讯过程,区别在foxmail发送EHLO指令时用的是一个名字,而indy缺少使用的是邮箱名字.通过直接使用Socket连接发送邮件测试,将EHLO改为名字后发送成功.
研究indy源码,发现indy中的smtp控件的HelloName属性如果有值的话就使用该属性值,没有值的话则使用其他值:
if HeloName <> '' then begin
    LNameToSend := HeloName;
  end else begin
    //Note:  IndyComputerName gets the computer name.
    //This is not always reliable in Indy because in Dot.NET,
    //it is done with This is available through System.Windows.Forms.SystemInformation.ComputerName
    //and that requires that we link to a problematic dependancy (Wystem.Windows.Forms).
    //Besides, I think RFC 821 was refering to the computer's Internet
    //DNS name.  We use the Computer name only if we can't get the DNS name.
     LNameToSend := GStack.HostName;
     if LNameToSend = '' then
     begin
       LNameToSend := IndyComputerName;
     end;
  end;
  if UseEhlo and (SendCmd('EHLO ' + LNameToSend ) = 250) then begin //APR: user can prevent EHLO    {Do not Localize}
    Capabilities.AddStrings(LastCmdResult.Text);
    if Capabilities.Count > 0 then begin
      //we drop the initial greeting.  We only want the feature list
      Capabilities.Delete(0);
    end;
  end else begin
    SendCmd('HELO ' + LNameToSend, 250);    {Do not Localize}
  end;
所有设置一下HelloName属性值即可以发送成功!
可能还有别的问题,待测!

你可能感兴趣的:(发送邮件)