Search The ForumSearch   RegisterRegister  LoginLogin

MailBee SMTP

 AfterLogic Forum : MailBee SMTP
Subject Topic: Timeout for GetRelayServer... Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Luca
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 01 February 2006 at 3:07pm | IP Logged Quote Luca

Hi,

is there a way to programmatically set a timeout for the new GetRelayServerFromEmailAddress method? It seems to hang when DNS is unreachable, for some reason, even if I set a very short timeout property to SMTP object. I also tried using a Timer object and setting EnableEvents as True, but had no luck.
Back to Top View Luca's Profile Search for other posts by Luca
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 02 February 2006 at 4:20pm | IP Logged Quote Alex

Could you please provide us with sample code which causes this problem (including DNS name you used, etc). In our tests, it returns empty string very quickly when DNS server is not available.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
Luca
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 07 February 2006 at 11:13pm | IP Logged Quote Luca

The code is really simple:

Dim oMailer As MailBee.SMTP
Set oMailer = New MailBee.SMTP
MsgBox oMailer.GetRelayServerFromEmailAddress("test@hotmail.com")

An easy way to reproduce the behaviour is using a firewall (I use Zone Alarm) and not allowing the compiled exe to connect to the Internet. The firewall asks the user what to do, and the software hangs until it is either blocked or allowed.

A second way is using a wrong DNS address (in the following example I just put a random address), which may not be an uncommon scenario with end users:

MsgBox oMailer.GetRelayServerFromEmailAddress("test@hotmail.com","1 23.45.31.17")

Program hangs for about 10 seconds. I suppose (but haven't tried) the same may happen when DNS address is right, but DNS server is unreachable.
Back to Top View Luca's Profile Search for other posts by Luca
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 08 February 2006 at 5:20am | IP Logged Quote Alex

Actually, 6 seconds is ok (I think you get 6 seconds, not 10 seconds). It would be a problem it was minutes or so.

Internally, the method performs the query two times, and waits 3 seconds each time. If it was less than 3 seconds, or it was just only one attempt to query DNS server, the results would not be reliable (the method would often say a particular address is invalid even if it's ok.)

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
Luca
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 08 February 2006 at 12:45pm | IP Logged Quote Luca

Thanx Alex. The idea was to use this function in a prog that sends some hundreds of emails; in this case even 6 seconds is quite a lot: so I was planning to use direct send only when the answer is very quick (1 second or less), otherwise switch to smtp relay. But, in order to achieve this, I would need to be able to set a shorter timeout.
Back to Top View Luca's Profile Search for other posts by Luca
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 08 February 2006 at 1:29pm | IP Logged Quote Alex

Thank you for the suggestion.

Please download the update at http://www.afterlogic.com/updates/mailbee.zip

It adds two parameters to GetRelayServerFromEmailAddress method so it now looks like:

GetRelayServerFromEmailAddress(EmailAddress,[DNSServer = ""], [SingleAttemptOnly=False], [Timeout=3])

When used as
Code:

SMTP.GetRelayServerFromEmailAddress("test@hotmail.com","192. 168.0.1",True,1)

it will use 1 second for timeout value and will attempt to send DNS query only once (no second attempt and attempts to query backup DNS servers will be made).

If the last two parameters are omitted, it works just like I described in my previous posting to keep compatibility with the existing code.

Please let us know if it works as expected.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
Luca
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 08 February 2006 at 8:29pm | IP Logged Quote Luca

Thank you Alex, that was great!

The best thing is that I can obtain the functionality I described with just 1 line of code:

SMTP.ServerName = SMTP.GetRelayServerFromEmailAddress("test@hotmail.com","192. 168.0.1",True,1)

If MX record is not found in 1 second, since the method returns an empty string SMTP relay is automatically used.

By the way, someone may be interested in how stable Mailbee is in large mailings: I've sent about 30.000 mails - don't worry, it's not spam :) - one after another with no performance problem at all; furthermore, since mail merge was used, message has been "reworked" 30.000 times (some other components that I have tested around ended up with messed-up mails or memory leaks).
Back to Top View Luca's Profile Search for other posts by Luca
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 09 February 2006 at 7:34am | IP Logged Quote Alex

Great news! Thank you for the valuable feedback.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide