This is one of those \'works locally, doesn\'t work on the server\' posts.
I have a simple contact form that sends an email. On the server, I get the following excep
I had a similar problem I simply added the following code in the Web.config file and it worked for me
<configuration>
<system.web>
.....
<trust level="Full" originUrl=""/>
</system.web>
</configuration>
I was facing this issue on my Shared Hosting Server. The error was coming up while trying to create an object of SMTP client and then assigning it a port number. Increasing trust level worked pretty well for me. I just elaborated details to make sure it helps some one else too. really appreciate the solution ! As I was unable to comment hence just thanked here the original author.
A low security level doesn't allow you to specify the smtp port. Default is port 25. Although my ISP specifies port 587, I can use port 25 and it works fine.