IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
Prestwood IT
Search Group:

Advanced
-Collapse +Expand Prestwood IT Store

Prestwood eMagazine

July Edition
Subscribe now! It's Free!
Enter your email:

   ► KBPrestwood I.T.Prestwood Pr...psSendMail DLL   Print This    All Groups  
  From the March 2012 Issue of Prestwood eMag
 
Prestwood IT psSendMail DLL:
Managing Connections in psSendMail
 
Posted 12 years ago on 1/25/2008
Take Away: A question has arisen about how best to manage SMTP connections when using psSendMail. Here are some tips:

KB100826

A question has arisen about how best to manage SMTP connections when using psSendMail.  Here are some tips:

psSendMail does not have any specific time-out for your SMTP connection.  But your SMTP server certainly should have a way to time-out idle connections. In fact, you should count on it.
 
If your program is designed to send email messages in response to certain, randomly timed events, like new database entries, it should take into account that long periods may transpire between such events.
 
In such a case, your use of psSendMail should be an “in-fast / out-fast” design.  That is, when the event occurs, make the connection, send the message, and then close the connection.  Don't leave the connection open indefinitely - expecting it to still be open at some undetermined future time.  Your SMTP server may well close the connection according to its time-out rules.
 
If your program is designed to send a bunch of messages based upon a fast loop - say through database records - you can (theoretically) open the connection once, send each message successively, then close the connection.
 
I say "theoretically" because, even in the latter case, it may be prudent to limit the number of messages sent at once.  We do this in the distribution of our E-Magazine.  We send out a few, say 20, and then wait a while before sending the next batch.
 
The reason for this?  SMTP servers can be very busy programs.  They are not only sending your batches, they are simultaneously contending with messages coming in from other users.  At some point, it's conceivable that their queue storage will run out - if they're not allowed some breathing room.  Even if you have an entire SMTP server to yourself, you could overrun its queue.  SMTP servers have a lot of work to do with each message they process, and psSendMail is FAST - it has no built-in "throttle."
 
When I say it's fast, I mean that the DLL is highly optimized, native machine code.  There isn't an interpreter or script responder in sight.  The performance of each call in psSendMail is limited (virtually) only by the time it takes the SMTP server to respond - meaning it's potentially faster than some SMTP servers, themselves.
 
Finally, consider how spam-paranoid servers may respond to a horde of messages, all originating from the same place in rapid succession.  Such an event may be all it takes for the SMTP server to say "Whoa, there! Looks like spam to me.  I'm closing that guy's connection."

Speaking of spam, psSendMail's documentation includes several tips for ensuring that your legitimate emails make it past the spam police.


Comments

0 Comments.
Share a thought or comment...
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P151A1
Enter key:
KB Post Contributed By Wes Peterson:

Wes Peterson is a Senior Programmer Analyst with Prestwood IT Solutions where he develops custom Windows software and custom websites using .Net and Delphi. When Wes is not coding for clients, he participates in this online community. Prior to his 10-year love-affair with Delphi, he worked with several other tools and databases. Currently he specializes in VS.Net using C# and VB.Net. To Wes, the .NET revolution is as exciting as the birth of Delphi.

Visit Profile

 KB Article #100826 Counter
18395
Since 4/2/2008
Sales Website: www.prestwood.com Or visit our legacy sales site: 
legacy.prestwood.com


©1995-2020 Prestwood IT Solutions.   [Security & Privacy]