INDY obsługa smtp

0

Witam,
Ostatnio próbuję poznać obsługę smtp w c++ builderze. Jednak mam problem. Według moich spostrzeżeń programik łączy się z serwerem jednak nie wysyła wiadomości, a po chwili wyskakuje socket error. Jakby ktos nie miał co robic wrzucam kod :D

 //---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
        IdMessage1->Clear();
        IdSMTP1->Host = "smtp.wp.pl" ;
        IdSMTP1->UserId = "[email protected]";
        IdSMTP1->Password = "xxxxxxx";
        IdSMTP1->Port = 465;
        IdSMTP1->AuthenticationType = atLogin;
        IdMessage1->From->Text = "abc";
        IdMessage1->Recipients->EMailAddresses= "[email protected]";
        //IdMessage1->ReceiptRecipient ="[email protected]";
        IdSMTP1->Connect();
        IdSMTP1->Send(IdMessage1);

}
//---------------------------------------------------------------------------
void __fastcall TForm1::IdSMTP1Connected(TObject *Sender)
{
        ShowMessage("sukces");
}
//---------------------------------------------------------------------------
0

1.Wywołaj w jakimś bezpieczniejszym sposobem np onclick z buttona
2.Posyłasz nic? IdMessage1->Clear(); Wpisz tam dane wiadomości!
3. Po connect daj try i dodaj disconnect poza tym powinno śmigać.

0

W OnClick dać tylko try i send?

0
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)

              {
              IdMessage1->From->Name = "kgb";
              }


//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{


        IdMessage1->From->Address = "[email protected]" ;
        IdSMTP1->Host = "smtp.wp.pl" ;
        IdSMTP1->UserId = "[email protected]";
        IdSMTP1->Password = "xxxxxx";
        IdSMTP1->Port = 465;
        IdSMTP1->AuthenticationType = atLogin;
        IdMessage1->From->Text = "abc";
        IdMessage1->Subject = "abc";
        IdMessage1->Body->Append("abc") ;

        IdMessage1->Recipients->EMailAddresses= "[email protected]";
        //IdMessage1->ReceiptRecipient ="[email protected]";
        IdSMTP1->Connect();
                 try
        {
                IdSMTP1->Send(IdMessage1);
        }
         __finally
        {
                IdSMTP1->Disconnect();
        }
 }


//---------------------------------------------------------------------------
  void __fastcall TForm1::IdSMTP1Connected(TObject *Sender)
{
        ShowMessage("connected");
} 

Zastosowałem się do twoich wskazówek, ale chyba nie do końca zrozumiałem, bo wywala po 3-4 minutach Socket error 10054

0

spróbuj jeszcze na porcie 587, kod wygląda dobrze, port 465 jest do ssl smtp

1 użytkowników online, w tym zalogowanych: 0, gości: 1