with idmessage1 do begin
      Subject := 'sdfkdsjflkds';  //邮件主题
      Body.add('我爱你!!!');//邮件正文
      From.text:= '[email protected]'; //发件人地址
      ReplyTo.EMailAddresses :='[email protected]';  //回复地址
      Recipients.EMailAddresses := '[email protected]'; //目的地址
    end;
    //以下是邮件服务器的信息;
   idsmtp1.Host:='smtp.126.com';
   idsmtp1.Username:='jiangyugang';
   idsmtp1.Password:='***************'; 密码正确
   idsmtp1.Port:=25;
  try
     idsmtp1.Connect;
     if idsmtp1.Connected=true then
     begin
       showmessage('连接成功!!!');
     end;
     idsmtp1.Send(idmessage1); //到这一步时就报错????请问是什么原因
  except
      showmessage('发送失败!!');
  end;
     idsmtp1.Destroy;
end;

解决方案 »

  1.   

    出什么错误?
    用的delphi7 + Indy9吗,使用老版本的Indy控件编写垃圾邮件发送工具的太多了,而老的indy控件有固定发送特征码,所以很多邮件服务器屏蔽了indy。
      

  2.   

    恩, 楼上说的情况存在哦.  服务器判断的就是客户端的版本信息.
    不过,请你检查下你的idsmtp设置  有个发送身份验证的方式,需要设置下.
    我只知道协议里面 服务器会问你用户名和密码 加密方式有几种 也许问题出在这里...220 126.com Anti-spam GT for Coremail System (126com[071018])250 OK334 dXN*****bWU6334 UGF*****cmQ6235 Authentication successful250 Mail OK250 Mail OK354 End data with <CR><LF>.<CR><LF>250 Mail OK queued as smtp2,DMmowLCL0mSCvuhI95CqUQ==.27976S2 1223212677221 Bye以上是一段完整的交互回话  问题应该是出在 334那里的...
    你回答服务器 "AUTH LOGIN"的时候 有BASE64加密 明文 还有一种什么加密... 一定要选对....能想到的就这些了 好运!
      

  3.   

    看一下idSMTP的UseEhlo是否为true,对于126的邮件,需要设置为true,即服务器要求身份验证.
      

  4.   

    我这里有用Delphi发送邮件的源程序!
      

  5.   

    begin
      Result := False;
      try
        //获得邮件主体讯息
        idmsgDemo.Clear;
        idmsgDemo.From.Text := Trim(FromNameE.Text); //发信人
        idmsgDemo.ReplyTo.EMailAddresses := Trim(FromAddrE.Text); //回信邮箱
        idmsgDemo.Recipients.EMailAddresses := Trim(AddressE.Text); //目标邮箱
        idmsgDemo.Priority := TIdMessagePriority(0); //邮件优先级
        idmsgDemo.Subject := Trim(SubjectE.Text); //邮件主题
        //idmsgDemo.Body.Text := Trim(MessageM.Text);
        idmsgDemo.Body.Assign(MessageM.Lines); //邮件正文    //设置SMTP
        idsmtpDemo.Host := Trim(HostE.Text);  //服务器地址
        idsmtpDemo.Port := StrToInt(Trim(PortE.Text));  //服务端口
        idsmtpDemo.Username := Trim(LoginE.Text);       //登录名(用户名)
        idsmtpDemo.Password := Trim(PasswordE.Text);    //密码    if idsmtpDemo.Connected then idsmtpDemo.Disconnect;
        idsmtpDemo.AuthenticationType := atLogin;
        idsmtpDemo.Connect;
        if not idsmtpDemo.Authenticate then
        begin
          ShowMessage('登录失败!');
          Exit;
        end;
        try
          idsmtpDemo.Send(idmsgDemo);
        except
          on E: Exception do
          begin
            ShowMessage(e.Message);
            Exit;
          end;  
        end;
        Result := True;    
      finally
        idsmtpDemo.Disconnect;
      end;   
    end;这个是我半年前写的,可以运行LZ的问题我那个时候好像也碰到过我比较了一下我的和LZ的代码,LZ不妨学我重新写一步登录看看
      

  6.   

    请将用Delphi发送邮件的源程序发我!
    谢谢!
    QQ:[email protected]
      

  7.   

    请问:在点击发送后出现error: authentication failed是什么原因!怎么解决?
    还有就是error: need EHLO and AUTH first怎么解决?
    谢谢!
      

  8.   

    不好意思,分太少,我现在都没有怎么用delphi了。