views:

374

answers:

4

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?

A: 

It seems the port is not 587. Please check this page.

And I am not an expert of the area you are discussing. But I feel use of some bridging mechanism would help you. I found this article regarding bridging and it might be help you.

Chathuranga Chandrasekara
587 is a valid SMTP port for GMail. I have been using it for some time, before i got into this medium trust affair
Midhat
and the bridging link you mentioned is interesting, but this would have helped me if I intended to receive email. I want to send it
Midhat
+1  A: 

Gmail also Accepts Port 25 ; you just give Port 25; its Working For Me.,

A: 

I am also getting the same issue while using GMAIL. Earlier my port was 587. After changing it to 25 the issue was resolved. Please mail me and tell if it worked for you.

Thanks Ankit koolchippy1987 at yahoo.com

Ankit Gupta
A: 

oh, i have encountered this issue,my port was 587 and give me 'System.Net.Mail.SmtpPermission' error message, i and trying to find some topic in MS msdn, but i fond,.NET mail only support 25 port, thanks very much, i will try it use 25 port with gmail.

terence