碰到一个用delphi开发的程序,发布为window系统服务来发邮件及附件,我想知道这种邮件机制用的发件服务器是什么?
我在代码里没有发现,贴上其中一部分:
function Email_S.SendMail(aHost: String): Boolean;
begin
Result := false;
with IdSMTP do
  begin
Msg('Trying to sendmail via: ' + aHost);
  Host := aHost;
 Connect;
  Msg('Successful connect ... sending message '+attachfile);
  IdSMTP.Send(IdMessage);
  Msg('Attempting disconnect');
  Disconnect;
......
在调用SendMail时aHost的传入参数是根据收件人地址@后那串解析出来的一些域名(用  Resolve(LDomainPart))解析出来的。
先谢过了.

解决方案 »

  1.   

    给你一段例程解释看看
      //设置连接到服务器属性
       with  IdSMTP do
        begin
        Host:=Trim(HostName.Text);   //SMTP服务器地址
        Port:=StrToInt(Trim(HostPort.Text));     //SMTP服务器端口
        UserName:=Trim(EditUser.Text);           //用户账号
        Password:=Trim(EditPass.Text);           // 用户密码
        end;
        //连接到服务器
        MemoInfo.Lines.Add('准备连接到服务器!'+HostName.Text);
        try
          IdSMTP.Connect();  //调用 Connect连接服务器
          except             //连接失败
             begin
              MemoInfo.Lines.Add('无法连接到服务器!'+HostName.Text);
              Exit;
            end ;
          end;
         //身份验证
         //检测SMTP服务器是否需要验证
          if (IdSMTP.AuthSchemesSupported.IndexOf ( 'LOGIN' ) <> -1)   then
             begin   //服务器要求验证
              MemoInfo.Lines.Add('服务器要求验证');
              IdSMTP.AuthenticationType:=atlogin;
               end
           else
               begin  //服务器不要求验证
                   MemoInfo.Lines.Add('服务器不需要验证');
               end;
            MemoInfo.Lines.Add('开始验证');
          try
              if IdSMTP.Authenticate then    //验证通过
                 MemoInfo.Lines.Add('服务器验证通过')
              else
                 MemoInfo.Lines.Add('服务器验证失败'); //验证失败
        except
            begin
                MemoInfo.Lines.Add('服务器验证失败');
                IdSMTP.Disconnect;            exit;
             end;
          end;
          //发送信件
           try
            IdSMTP.Send(MailMessage);
           
           except
              MemoInfo.Lines.Add('发送失败');
              end;
              IdSMTP.Disconnect;
           //发送完成