想做一个发送EMail的程序,要内置SMTP服务器,如何做?

解决方案 »

  1.   

    SMTP服务,关键应该在于MX记录及其相应Mail域名解析,邮件暂存及转发,除此之外就是一项普通的网络服务。
      

  2.   

    利用outlook
     Outlook := CreateOLEObject('Outlook.Application');
      if VarIsEmpty(Outlook) then
      begin
        MessageBox(handle, 'Outlook ¦Û°Ê¤Æ¹ï¶H³Ð«Ø¥¢±Ñ¡I', nil, 0);
        Exit;
      end;  OutlookNameSpace :=Outlook.GetNamespace('MAPI');
      OutlookFolder:=OutlookNameSpace.GetDefaultFolder(3);
      myDistList :=OutlookFolder.Items;
      Mail := Outlook.CreateItem(olMailItem); //olMailItem=1
      cipient:=Mail.Recipients.Add('[email protected]');
      cipient.Type:=olTo;
      Mail.Body := '';
      Mail.Send;
      Outlook := Unassigned;
      Mail := Unassigned;
      

  3.   

    如果要內置SMTP服務器的話,用TIDSMTP,IDmsgSend控件做,
      with IdMsgSend do
      begin
        body.Clear;
        body.Add(bodyText);
        From.Text := Frommail;
        Recipients.EMailAddresses := Usermail; { To: header }
        Subject := subjectText; { Subject: header }
        ReceiptRecipient.Text := '';
    //    TIdAttachment.Create(IdMsgSend.MessageParts, bodytext1);
      end;
      SMTP.AuthenticationType := atLogin;
      SMTP.Username := 'dreamy';
      SMTP.Password := '1111';  {General setup}
      SMTP.Host := '????';//你的郵件服務器地址;
      SMTP.Host :=mailip;
      SMTP.Port := 25;  {now we send the message}
      SMTP.Connect;
      try
        try
          SMTP.Send(IdMsgSend);
          result := True;
        except
          result := False;
        end;
      finally
        SMTP.Disconnect;
      end;