Mam problem odnośnie autoryzacji, gdybym miał wysłać normalną pocztę wszystko by było bez problemu, leczy gdy wprowadzono autoryzację, to jest spory problem (jak dla mnie). Mam program do wysyłania maila, przytocze kod najprostrzego programu znajdującego się w examples C++ buildera
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "smtpmain.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TFormMain *FormMain;
//---------------------------------------------------------------------------
__fastcall TFormMain::TFormMain(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Button1Click(TObject *Sender)
{
NMSMTP1->Host = Edit1->Text;
NMSMTP1->Port = StrToInt(Edit2->Text);
NMSMTP1->UserID = Edit4->Text;
NMSMTP1->Connect();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Button2Click(TObject *Sender)
{
if (NMSMTP1->Connected)
NMSMTP1->Disconnect();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Button6Click(TObject *Sender)
{
NMSMTP1->PostMessage->FromAddress = Edit6->Text;
NMSMTP1->PostMessage->FromName = Edit5->Text;
NMSMTP1->PostMessage->Subject = Edit10->Text;
NMSMTP1->PostMessage->ToAddress->Add(Edit7->Text);
NMSMTP1->PostMessage->ToBlindCarbonCopy->Add(Edit9->Text);
NMSMTP1->PostMessage->ToCarbonCopy->Add(Edit8->Text);
NMSMTP1->PostMessage->Attachments->AddStrings(ListBox1->Items);
NMSMTP1->PostMessage->Body->Assign(Memo1->Lines);
NMSMTP1->SendMail();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Button4Click(TObject *Sender)
{
if (OpenDialog1->Execute())
ListBox1->Items->Add(OpenDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Button5Click(TObject *Sender)
{
ListBox1->Items->Delete(ListBox1->ItemIndex);
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Button3Click(TObject *Sender)
{
if (NMSMTP1->Verify(Edit3->Text))
ShowMessage(Edit3->Text+" exists");
else
ShowMessage(Edit3->Text+" not verified");
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Button7Click(TObject *Sender)
{
NMSMTP1->ExpandList(Edit11->Text);
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1Connect(TObject *Sender)
{
StatusBar1->SimpleText = "Connected";
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1ConnectionFailed(TObject *Sender)
{
ShowMessage("Connection Failed");
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1ConnectionRequired(bool &handled)
{
AnsiString BoxCaption;
AnsiString BoxMsg;
BoxCaption = "Connection Required";
BoxMsg = "Connection Required. Connect?";
if (MessageBox(0, &BoxMsg[1], &BoxCaption[1], MB_YESNO + MB_ICONEXCLAMATION) == IDYES)
{
handled = TRUE;
Button1Click(this);
}
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1Disconnect(TObject *Sender)
{
if (StatusBar1 != 0)
StatusBar1->SimpleText = "Disconnected";
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1EncodeEnd(AnsiString Filename)
{
StatusBar1->SimpleText = "Encoding "+Filename;
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1EncodeStart(AnsiString Filename)
{
StatusBar1->SimpleText = "Decoding "+Filename;
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1Failure(TObject *Sender)
{
ShowMessage("Operation Failed");
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1HostResolved(TComponent *Sender)
{
StatusBar1->SimpleText = "Host Resolved";
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1InvalidHost(bool &handled)
{
AnsiString NewHost;
if (InputQuery("Invalid Host", "Please Choose another host", NewHost))
{
//ShowMessage(NewHost);
NMSMTP1->Host = NewHost;
handled = true;
}
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1MailListReturn(AnsiString MailAddress)
{
Memo2->Lines->Add(MailAddress);
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1PacketSent(TObject *Sender)
{
StatusBar1->SimpleText = IntToStr(NMSMTP1->BytesSent)+" bytes of "+IntToStr(NMSMTP1->BytesTotal)+" sent";
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1RecipientNotFound(AnsiString Recipient)
{
ShowMessage(Recipient+" not found");
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1SendStart(TObject *Sender)
{
StatusBar1->SimpleText = "Sending message";
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1Status(TComponent *Sender, AnsiString Status)
{
if (StatusBar1 != 0)
StatusBar1->SimpleText = Status;
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::NMSMTP1Success(TObject *Sender)
{
StatusBar1->SimpleText = "Message Sent";
}
//---------------------------------------------------------------------------
plik nagłowkowy
//---------------------------------------------------------------------------
#ifndef smtpmainH
#define smtpmainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include <ExtCtrls.hpp>
#include <Dialogs.hpp>
#include <NMsmtp.hpp>
#include <Psock.hpp>
//---------------------------------------------------------------------------
class TFormMain : public TForm
{
__published: // IDE-managed Components
TPageControl *PageControl1;
TTabSheet *TabSheet1;
TLabel *Label1;
TLabel *Label2;
TLabel *Label4;
TEdit *Edit1;
TEdit *Edit2;
TButton *Button1;
TButton *Button2;
TEdit *Edit4;
TGroupBox *GroupBox1;
TLabel *Label5;
TLabel *Label6;
TEdit *Edit5;
TEdit *Edit6;
TTabSheet *TabSheet2;
TLabel *Label11;
TMemo *Memo1;
TPanel *Panel1;
TLabel *Label7;
TLabel *Label8;
TLabel *Label9;
TLabel *Label10;
TEdit *Edit7;
TEdit *Edit8;
TEdit *Edit9;
TListBox *ListBox1;
TButton *Button4;
TButton *Button5;
TEdit *Edit10;
TButton *Button6;
TTabSheet *TabSheet3;
TLabel *Label3;
TEdit *Edit3;
TButton *Button3;
TTabSheet *TabSheet4;
TLabel *Label12;
TLabel *Label13;
TEdit *Edit11;
TMemo *Memo2;
TButton *Button7;
TStatusBar *StatusBar1;
TOpenDialog *OpenDialog1;
TNMSMTP *NMSMTP1;
void __fastcall Button1Click(TObject *Sender);
void __fastcall Button2Click(TObject *Sender);
void __fastcall Button6Click(TObject *Sender);
void __fastcall Button4Click(TObject *Sender);
void __fastcall Button5Click(TObject *Sender);
void __fastcall Button3Click(TObject *Sender);
void __fastcall Button7Click(TObject *Sender);
void __fastcall NMSMTP1Connect(TObject *Sender);
void __fastcall NMSMTP1ConnectionFailed(TObject *Sender);
void __fastcall NMSMTP1ConnectionRequired(bool &handled);
void __fastcall NMSMTP1Disconnect(TObject *Sender);
void __fastcall NMSMTP1EncodeEnd(AnsiString Filename);
void __fastcall NMSMTP1EncodeStart(AnsiString Filename);
void __fastcall NMSMTP1Failure(TObject *Sender);
void __fastcall NMSMTP1HostResolved(TComponent *Sender);
void __fastcall NMSMTP1InvalidHost(bool &handled);
void __fastcall NMSMTP1MailListReturn(AnsiString MailAddress);
void __fastcall NMSMTP1PacketSent(TObject *Sender);
void __fastcall NMSMTP1RecipientNotFound(AnsiString Recipient);
void __fastcall NMSMTP1SendStart(TObject *Sender);
void __fastcall NMSMTP1Status(TComponent *Sender, AnsiString Status);
void __fastcall NMSMTP1Success(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TFormMain(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern TFormMain *FormMain;
//---------------------------------------------------------------------------
#endif
Może ten kod jest pełny?? czyli powinien wysłać maila?? w każdym razie mi nie działa... tzn łączy się z siecią, wszystko jest ok próbuje wysłać maila i dostaje wiadomość z boxa
jeżeli img nie działa to ling
http://image-share.com/viewer.php?id=viu1230586654i.JPG
Przeczytałem gdzieś, a dokładnie w kilku miejscach, żeby wykorzystać auth login, tylko nie mam pojęcia "z czym to się je" i "od której strony ugryźć". Jeżeli ktoś by mi pomógł i napisał, tzn wyjaśnił mniej więcej o co w tym chodzi, a najlepszym wyjsciem byłoby wklejenie kodu, wytłumaczenie gdzie to wkleić i dlaczego.
edit:
Odświeżam