views:

163

answers:

3

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.

+1  A: 

It could be lots of things, from credential problems, DNS issues, or...who knows. Is it unable to send as in you get an error or as in they appear to go but never arrive?

Are you sure the WSA tool is going through SMTPClient, or are you just assuming it (I don't know myself)?

-- MarkusQ

I am getting a Security Exception on my mail

That sounds like a credentials problem then, or a trust issue. Are you sure you're running at medium (or higher) trust? What's the rest of the error?

-- MarkusQ

MarkusQ
I am getting a Security Exception on my mail, flawless end with microsoft's admin stuff. I don't know for sure that WSA uses SMTPClient, but I think sockets are disabled for medium trust, so it's an educated guess.
Präriewolf
+1  A: 

Try checking your web.config file: is the WSA tool updating these settings?

This element is under the configuration element

<system.net>
<mailSettings>
  <smtp deliveryMethod="Network" from="[email protected]">
    <network
         host="your.gateway.com"
         userName="[email protected]"
         password="your_password"
         port="25" />
  </smtp>
</mailSettings>
</system.net>
Nils
+1  A: 

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.

Präriewolf