Send Email on GMail SMTP under medium trust

Posted by Midhat on Stack Overflow See other posts from Stack Overflow or by Midhat
Published on 2009-05-11T12:39:32Z Indexed on 2010/05/29 18:32 UTC
Read the original article Hit count: 344

Hi

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?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about smtp