unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdMessage, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP;type
  TForm1 = class(TForm)
    IdSMTP1: TIdSMTP;
    IdMessage1: TIdMessage;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
IdSMTP1.Username :='aa13580127332'; //服务器上的用户名
IdSMTP1.Password :='aa1988710'; //服务器上的密码
IdSMTP1.Host :='smtp.163.com'; //服务器SMTP地址
IdSMTP1.Port :=25; //服务器端口
IdSMTP1.Connect; //建立连接
end;procedure TForm1.Button1Click(Sender: TObject);
begin
IdMessage1.Body.Add( ' 呵呵,感谢Edwgdfsgfdgdsdsfgdsfdfgddfgdfdgf@rd吧' );
 //邮件正文件内容
IdMessage1.From.address :='[email protected]'; //发件人地址
IdMessage1.Recipients.EMailAddresses :='[email protected]'; //收件人地址,这里改为你的EMAIL地址
IdMessage1.Subject:='发送邮件就这么简单' ; //邮件标题
IdMessage1.Priority := mphigh; //优先级,mphigh为最高级。
IdSMTP1.Send(IdMessage1); //发送邮件
end;end.照足网上的做但还是没有发送成功!求解。错误为:
----------------------------------------------------------------------------------
project project2.exe raised exception class eidprotocolreplyerror with message
'authentication is required.smtp14,escowkdlk3hx6nhm49olaq---829s3 1289283673
process stopped.use step or run to continue.
                   ok    help
------------------------------------------------------------------------------

解决方案 »

  1.   

    现在对于163的邮箱,用基本设置是无效的,需要进行进一步的验证,具体的到网上查一下吧,我记得以前查到过,还有一些邮箱,需要开通smtp服务,否则也无法发送
      

  2.   

    试一下设置为:
    IdSMTP1.UseEHLO := true
      

  3.   

    IdSMTP1.UseEHLO := true ;这个不行啊!
      

  4.   

    connect ; 后需要 authentication  下; 另外163的需要 useEhLO := true;
      

  5.   

    IdSMTP1.Auth 这个属性没有设置
      

  6.   

    function SendMail(MailAddress, MailSubject, MailBody: string):Boolean;
    var
      srv: TIdSMTP;
      msg: TIdMessage;
    begin
      srv := TIdSMTP.Create(nil);
      msg := TIdMessage.Create(nil);
      with srv do
      begin
        AuthenticationType := atLogin;
        Username := '****@11111.com';  //**邮件发送用户名
        Password := 'test';  //**邮件发送用户密码
        Host := 'mail.11111.com';  //**邮件服务器
        Port := 25;
        with msg do
        begin
          Clear;
          From.Address := '*****@1111.com';  //**发件人邮件地址
          From.Name := 'test';  //**发件人名字
          Recipients.EMailAddresses := MailAddress;
          Subject := MailSubject;
          Body.Add(MailBody);
        end;
        try
          begin
            Connect();
            Send(msg);
            Disconnect;
          end;
        except on E:Exception do
          begin
            ShowMessage(E.Message);
            Disconnect;
            Result := False;
            Abort;
            Exit;
          end;
        end;
      end;
      Result := True;
    end;