🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
2 messages
2 total messages Started by John MacDonald Wed, 09 Jul 2008 19:48
Looking for relaible SMTP tool with authentication
#198
Author: John MacDonald
Date: Wed, 09 Jul 2008 19:48
11 lines
1083 bytes
Hello Everyone:

I am looking to update one of my applications. I need a SMTP component that
will use authentication.

Someone wrote Indy, Synapse, ICS ??? Has anyone had experience with these
products working with C++ Builder 5 Enterprise.

Thanks in advance

JMAC out
Re: Looking for relaible SMTP tool with authentication
#26
Author: Mark Jacobs
Date: Tue, 05 Aug 2008 14:16
70 lines
3627 bytes
"John MacDonald" <jmac@itmeasures.com> wrote in message 
news:48751525$1@newsgroups.borland.com...
> I am looking to update one of my applications. I need a SMTP component that
> will use authentication.
> Someone wrote Indy, Synapse, ICS ??? Has anyone had experience with these
> products working with C++ Builder 5 Enterprise.

I have successfully implemented SMTP in my apps using the ICS by Francois Piette (a very 
fine programmer indeed!). It is available at http://www.overbyte.be/frame_index.html 
(click on the ICS link on the left-hand side menu).

Since I also use C++ Builder 5, here is some sample code for you (mjsmtp is the ICS SMTP 
component I dropped on the form, you are Steve Jobs, and you are sending an email to Bill 
Gates) :-

Usage :-

mysendit("The body of the message which could contain HTML if you like.");

Implementation :-

AnsiString mysendit(AnsiString yurmess)
{
  int ii,ctr=20,dly=500;
 // ctr is max number of retries, dly is delay in msec between each try
  if (!mjsmtp) return er+"No EMail Component";
  mjsmtp->RcptName->Text="Bill Gates <billg@microsoft.com>";
  mjsmtp->HdrFrom="Steve Jobs <stevej@apple.com>";
  mjsmtp->HdrTo="Bill Gates <billg@microsoft.com>";
  mjsmtp->HdrSubject="For Your Eyes Only!";
  mjsmtp->SignOn="Your SMTP User ID";
  mjsmtp->FromName="Steve Jobs <stevej@apple.com>";
  mjsmtp->EmailFiles->Text="Attach1.doc;Attach2.xls";
  mjsmtp->Host="Your SMTP Host";
  mjsmtp->PlainText->Text=""; mjsmtp->HtmlText->Text="";
  if (yurmess.LowerCase().Pos("<html")>0)
  {
    mjsmtp->ContentType=smtpHtml; mjsmtp->HtmlText->Text=yurmess;
  }
  else
  {
    mjsmtp->ContentType=smtpPlainText; mjsmtp->PlainText->Text=yurmess;
  }
  mjsmtp->Open(); ii=0;
  while (mjsmtp->State!=smtpReady && mjsmtp->State!=smtpAbort && ii<ctr)
  {
    Sleep(500); ++ii;
  }
  if (mjsmtp->State==smtpAbort || ii>=ctr) return "Open Aborted";
  mjsmtp->Mail(); ii=0;
  while (mjsmtp->State!=smtpReady && mjsmtp->State!=smtpAbort && ii<ctr)

  {
    Sleep(500); ++ii;
  }
  if (mjsmtp->State==smtpAbort || ii>=ctr) return "EMail Aborted";
  return  "EMail Sent OK "+Now().DateTimeString()+" "+mjsmtp->LastResponse;
}

As you can see, this is very much a synchronous operation, so you may want to put it into 
a separate thread. Anyway, good luck - I hope that gets you going. As for validation, 
you'll have to dig through the properties and methods in the ics\Delphi\Vc32\SmtpProt.pas 
file. Here is what I found :-

procedure TCustomSmtpClient.Auth;

at row 1448 in the .pas file.
-- 
Mark Jacobs
http://www.dkcomputing.co.uk 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads