I need to send an email from my app, which will be running under medium trust. My current email sending code that works fine under full trust throws SecurityException under medium trust
[SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
Examining my machine.config and allied files reveal that my SMTP access is restricted to Connect.
<SecurityClass Name="SmtpPermission" Description="System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
and
<IPermission class="SmtpPermission" version="1" Access="Connect"/>
According to MSDN, Connect allows request on port 25 only. But Gmail servers work on port 587. Any workarounds? suggestions?