Medium Trust / SMTP

Post here for help with installing or upgrading mojoPortal pre-compiled release packages. When posting in this forum, please provide all relevant details. You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

Post here for help with installation of mojoPortal pre-compiled release packages

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.

You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

This thread is closed to new posts. You must sign in to post in the forums.
8/19/2008 6:50:05 PM
Gravatar
Total Posts 2

Medium Trust / SMTP

Hi,

I'm running mojoPortal 2.2.6.7 on MSSQL2005 w/Medium Trust, and everything seems to work - except the mail feature (whether in Contact Form or when registring a user).

 

It always shows a message that the mail was sent, however when I enable the trace  -

__ 

ERROR mojoPortal.Net.Email [(null)] - error sending email, message was:

....

DotNetOpenMail.MailException: Could not connect to XX.XXX.XX.XX:XX ---> System.Security.SecurityException: Request for the permission of type 'System.Net.SocketPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)

at System.Security.CodeAccessPermission.Demand()

at System.Net.Sockets.Socket.CheckCacheRemote(EndPoint& remoteEP, Boolean isOverwrite)

at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)

at System.Net.Sockets.TcpClient.Connect(IPEndPoint remoteEP)

at DotNetOpenMail.SmtpProxy.Open()

The action that failed was:

Demand

The type of the first permission that failed was:

System.Net.SocketPermission

The Zone of the assembly that failed was:

MyComputer

--- End of inner exception stack trace ---

at DotNetOpenMail.SmtpProxy.Open()

at DotNetOpenMail.SmtpServer.Send(ISendableMessage emailMessage, EmailAddressCollection rcpttocollection, EmailAddress mailfrom)

at DotNetOpenMail.EmailMessage.Send(SmtpServer smtpserver)

at mojoPortal.Net.Email.SendEmail(String from, String to, String cc, String bcc, String subject, String messageBody, Boolean html, String priority)

__


 I've set up everything in appSettings / system.net, used the medium trust web.config file, tried several smtp servers (none on the local server), changed the and other than the smtp issue - everything works great.

Unfortunately there isn't any error message (to indicate that the email wasn't sent) , unless I enable trace.

I don't know if it's a mojoPortal prob or server - I don't have direct access to the server, so I don't know how the guys there configured it (though it seems to be working fine). If it's a configuration issue at the server.. I have no idead where to start. 

 

Thanx,

Daniel. 

8/20/2008 6:12:07 AM
Gravatar
Total Posts 18439

Re: Medium Trust / SMTP

Hi,

Yes its true sending mail by smtp does not work in Medium Trust, a quick google of "medium trust smtp" confirms this problem. Rick Strahl has a discussion of it here.

My understanding is that most good hosting providers make it possible to relay mail through their own mail servers, so if you are using smtp credentials and server provided by them it should work whereas if relaying through something like yahoo mail will not.

In any case its an issue you'll have to take up with your host to solve it. I cannot change the fact that smtp doesn't work in Medium Trust. Good hosting companies will usually tweak their policy files to allow this in medium trust to meet their customer needs.

Hope it helps,

Joe

8/20/2008 6:36:02 AM
Gravatar
Total Posts 18439

Re: Medium Trust / SMTP

Hi,

I take it back, after reading a little more, smtp should work in Medium Trust as long as its using the default smtp port 25.

The problem in mojoPortal is we are using the more advanced DotNetOpenMail instead of the built in System.Net.Mail stuff. I will look into this and add a switch so that if running in Medium trust we will use the built in stuff, then at least it will work if sending on port 25. Unfortuantely, many email providers like Yahoo and Google use alteranate ports so those won't work even afer I fix this.

Best,

Joe

8/20/2008 6:48:46 AM
Gravatar
Total Posts 18439

Re: Medium Trust / SMTP

I have implemented fallback to built in System.Net classes for sending email under Medium Trust. The fix will be in svn trunk by tonight for developers and will be in the next release for everyone else.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.