We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

SMTPClient - Send TimeOut Not As Expected

I set the Timeout of SMTPClient to 30000 milliseconds and expect the send to timeout at the specified milliseconds when there is an issue, however when the Port Number is incorrect (Tried 584 instead of 587 on smtp.office365.com), I see the send waits for nearly 8 minutes to timeout. Please advise.

Hi Sathyapriya,

Thank you for posting your query.

I was able to reproduce this issue at my end with an Office365 test account. The issue has been reported to our development team as EMAILNET-34855 for further consideration. We’ll notify you here once there is some information or a fix version available in this regard.

Thank you Kashif. Please could you give me a timeframe for this fix to be ready?

Hi Sathyapriya,

The issue is yet to be investigated by our development team and, hence, no fix version is available for this issue at present. You may please inquire again about the status of this issue after a couple of weeks and we shall share any available information about the issue.

Hi, I am also having the same issue and would like some clarrification…

SMTPClient has two properties “Timeout” and “ConnectionTimeout” and the documentation does not have any specific detail on how these apply when sending an email. I’ve made the assumption that “ConnectionTimeout” applies when attempting to connect to the SMTP server, and “Timeout” is for the actual transmission of the email, but my tests do not support this.

I have set the “ConnectionTimeout” to 5000 (5 seconds) and the “Timeout” to 10000 (10 seconds), but when I attempt to send an email to an invalid server address it waits 42 seconds before throwing a timeout exception. Changing either timeout property does not affect this delay in any way.

So, I have 2 questions:

1) What property do I set to control when the timeout exception is thrown in the scenario above (no response from the server). It doesn’t seem to be either of these.

2) Can you please provide a technical description for these two properties so that I can use them appropriately.

Further to my last post, I did some more testing to different servers with the same timeout property settings (ConnectionTimeout=15000 and Timeout=10000), and each one times out at a different interval.

Here are the results. All 3 servers are invalid as that’s what I’m testing for so they should produce no response to the send request.

smtp.gmail.com (port 222) - timeout after 207 seconds
invalid IP address on local subnet - timeout after 42 seconds
localhost (port 25) - timeout after 104 seconds

Each test was repeated 3 times giving exactly the same result, so it’s consistent per server, but it should be the same regardless of the server.

This makes it impossible for our software to behave in a predictable manor. We need a way to specify a timeout and have it actually throw the timeout exception after that exact amount of time.

Hi David,

Thank you for your inquiry.

The descriptions of both these properties as from our offline CHM help file are as follow:

ConnectionTimeOut: Gets or sets the connection timeout Please note: If connection consists of several server requests, for every request will assigned this timeout value.

TimeOut: Gets or sets the timeout Please note: If an operation consists of several server requests, for every request will assigned this timeout value.

We have further tested this issue by setting both these properties to specific values but timeout is not respected. We have further added comments to the logged ticket so that product team can look into these and share their feedback. Once there is some information available, we shall update you here via this thread.

The issues you have found earlier (filed as EMAILNET-34855) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

I see that this issue is not resolved yet. (Version 5.6.0)

I still receive a timeout only after nearly 6 mins on an office365 account when I set the timeout to 30 secs. Please advise.

Hi Sathyapriya,

We have tested this issue with the latest version of Aspose.Email for .NET 5.6.0 and the following code sample. The API is respecting the behavior set in ConnectionTimeOut property of the SmtpClient class. Please check the following sample code at your end that has a test account credentials of an Office 365 account. It is behaving as expected. Please let us know your feedback.

Sample Code:

<!–[if gte mso 9]>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>

MailMessage msg = new MailMessage("UserOne@Ase1984.onmicrosoft.com", "recipient@gmail.com", "test", "Body");

SmtpClient client = new SmtpClient("smtp.office365.com", 584, "UserOne@Ase1984.onmicrosoft.com", "Aspose1234");

client.SecurityOptions = SecurityOptions.Auto;

client.ConnectionTimeout = 40*1000;






catch (Exception ex)