Search code examples
asp.netsmtptrust

SMTPClient Half Working \ Half Not


I am using Microsoft's membership framework on a website. I am able to send password retrieval e-mails, but am unable to send e-mails myself using SMTPClient.

When you configure the SMTP settings in the Web Site Administration Tool, what are the settings that this application give it's SMTPclient?

If I know this, I can duplicate it and hopefully send e-mails.

A few items I've ruled out. - I'm using port 25, (which is the only one allowed under medium trust). - This code works on my local system.


Solution

  • I was attempting to pass the values for SMTPClient in with the constructor. What I failed to realize is that SMTPClient apparently automatically pulls the values from web.config and uses those.

    By trying to pass my own values (even though they where identical); I inadvertently violated trust levels causing a security exception.

    Don't pass in smtp info in the constructor, use web.config to set it up, and there should be no problem in medium trust.