When running ASP.NET in high and medium trust, ASP.NET 2.0+ SMTPClient related classes are not able to deliver emails if the port of the SMTP server is not 25.
This is not easily grasped from the documentation, but from the ASP.NET Code Access Security overview (http://msdn.microsoft.com/en-us/library/87x8e4d1.aspx) we can see the following table:
One has to go to the SmtpPermission definition and then the SmtpAccess enumeration to discover what Connect means:
This piece of configuration is really important in hosting or especially restrictive environments.
I found a workaround (in the case that you could create a custom policy definition) from Rick Strahl’s Web Log (SmtpClient in Medium Trust - Rick Strahl's Web Log):
<IPermission class="SmtpPermission" version="1" Unrestricted="true" />
Thanks to Rick by the tip.
I hope this post helps,