SMTPClient Half Working \ Half Not

孤街醉人 提交于 2019-12-24 00:16:57

问题


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:


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.




回答2:


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




回答3:


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="you@email.com">
    <network
         host="your.gateway.com"
         userName="your@email.com"
         password="your_password"
         port="25" />
  </smtp>
</mailSettings>
</system.net>


来源:https://stackoverflow.com/questions/587117/smtpclient-half-working-half-not

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!