Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Index of Chilkat Blog Posts

April 4, 2007

Minimizing SMTP Connections

Question:

I’m looking for an example or way to “spool” outgoing emails. I’m sending about 200’ish individual emails via my SMTP mail server and I get a message back from Comcast of “too frequent connects.” I’m assuming Comcast is trying to prevent someone from sending spam. I’m executing a “SendEmail” for each name on my list, therefore, there is an SMTP connection for each message. Is there a way to batch the messages together and group the smtp connections?

Answer:

The latest version of Chilkat Mail will keep the connection with the SMTP server open. There are a few as-yet-undocumented methods, all of which are entirely optional:

OpenSmtpConnection: Opens a connection with the SMTP server and authenticates.
	
CloseSmtpConnection: Closes the connection with the SMTP server.
	
SmtpNoop: Sends a No-op command to the SMTP server.  
	
SmtpReset: Resets the session with the SMTP server to the initial state by sending an RSET SMTP command.

The mailman.SendEmail method will automatically open a connection to the SMTP server if it is not already open. Otherwise it will use the existing connection. When a mailman object is destructed, the connection is automatically closed.

Thus, with the latest version of Chilkat Mail, if you have a loop that calls SendEmail in each iteration, the 1st iteration will establish the SMTP connection and all subsequent iterations will use the existing connection. If the connection is lost at any point, the next SendEmail call will automatically re-establish the connection. This applies to all mail-sending methods, such as SendMime, SendBundle, SendToDistributionList, etc.

The OpenSmtpConnection/CloseSmtpConnection methods can be used if you desire greater control over the SMTP connections.


Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.