I have this inside my Web.config:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="admin#xxxxxx.com">
<network defaultCredentials="false" host="mail.xxxxxx.com" password="xxxxxxx" port="25" userName="admin#xxxxxx.com" enableSsl="false" />
</smtp>
</mailSettings>
</system.net>
This causes any request to my website becomes
500 Internal Server Error
This makes the hosting server assumes that my Web.config is not valid. Before it was fine, my Web site can run with no problem. I cannot see any syntax error in it?
What is going on here?
Posting from comment thread as answer: You likely have a special character in your password that may require XML encoding.
Related
Current system that I working on has a email sending function with this configuration in Web.config as below
<mailSettings>
<!-- Method#1: Configure smtp server credentials -->
<smtp from="some-email#gmail.com">
<network enableSsl="true" host="smtp.gmail.com" port="587" userName="some-email#gmail.com" password="valid-password" />
</smtp>
<!-- Method#2: Dump emails to a local directory -->
<smtp from="some-email#gmail.com" deliveryMethod="SpecifiedPickupDirectory">
<network host="localhost" />
<specifiedPickupDirectory pickupDirectoryLocation="~/App_Data/EmailPickup" />
</smtp>
</mailSettings>
As the config shown about there is 2 method, but it only able to enable 1 method in a time, else it will cause error when i try to run the system.
Question: it there any config or setting can make both of the method work at the same time?
I want it send the email as well as pickup the email and drop it into the folder i specific on.
I was able to manually create a file with StreamWriter and save into folder but it require extra code to handle it.
We built an ASP.NET app that we deployed on the client's server, using their SMTP server.
I'm trying to have Elmah send error emails using the ErrorEmailModule. This uses the SMTP settings as configured in the web.config, but somehow sending emails is not working (nothing is being sent).
The SMTP settings are configured like this:
<system.net>
<mailSettings>
<smtp from="support#xxxxxx.nl">
<network host="xxxxxxx.management.local" port="25" enableSsl="true" defaultCredentials="true"/>
</smtp>
</mailSettings>
</system.net>
To test if this is a problem with Elmah or with the config I created a little test application that uses the same setting and tries to send an email:
string from = "support#xxxxxxxx.nl";
string to = ConfigurationManager.AppSettings["ErrorReportingEmail"];
var message = new MailMessage(from, to, "Test", "Test");
var smtpClient = new SmtpClient();
smtpClient.Send(message);
This doesn't work either. SmtpClient doesn't throw an error, it just acts like it sent an email, but I'm not receiving anything.
I then tried sending an email using 2 different email testing tools, called MailTester and MultiMail, I entered the same SMTP settings, and they can send emails just fine.
So my question is: why can I send emails from these mail tester apps but not from my ASP.NET app?
try this set deliveryMethod = network.
<system.net>
<mailSettings>
<smtp from="support#xxxxxx.nl" deliveryMethod="Network">
<network host="xxxxxxx.management.local" port="25" enableSsl="true" defaultCredentials="true"/>
</smtp>
</mailSettings>
</system.net>
I have an asp.net c# web forms application that utilizes the password recovery control. The password recovery sends an email with a new password when running it on my localhost. But when I try it from my Godaddy server it times-out.
Here's what I have:
Basic password recovery control:
<asp:PasswordRecovery ID="PasswordRecovery1" runat="server"></asp:PasswordRecovery>
web.config file has:
<mailSettings>
<smtp from="me#gmail.com">
<network host="smtp.gmail.com" password="mypwd" port="587"
userName="me#gmail.com" enableSsl="true" />
</smtp>
</mailSettings>
What do I need to do in order to get this working on GoDaddy?
I decided to use Godaddy (secureserver) email instead of Gmail. To get this to work simply change the web.config file to:
<mailSettings
<network host="relay-hosting.secureserver.net" />
</mailSettings>
I use the standard web.config 'mailSettings' as the backbone for my ASP.NET emails. However, I find it to being increasingly limited in capability. For example, I want to send emails from many different user accounts (support, sales, management etc.) and it doesn't seem like mailSettings supports this. Is there any way to avoid using mailSettings so that I can use multiple accounts? Any disadvantages (and if not, then why would anyone use mailSettings?)
<mailSettings>
<smtp from="support#company.com">
<network host="smtp.gmail.com" port="587" userName="support#company.com" password="abcPassword"/>
</smtp>
</mailSettings>
If you're sending your mail using a System.Net.Mail.MailMessage, you should be able to override the From in the web.config by setting the MailMessage.From to a new MailAddress.
here is the sitution, i am testing on my localhost from my machine at home (no proxy server and windows default firewall) and retrieving api.flickr.com xml file, when I come to work (that uses an ISA server to connect) I get "remote server could not be resolved" so I added these lines to the web.config
<system.net>
<defaultProxy>
<proxy
usesystemdefault="False"
proxyaddress="http://localhost"
bypassonlocal="True"
/>
<bypasslist>
<add address="[a-z]+\.flickr\.com\.+" />
</bypasslist>
</defaultProxy>
</system.net>
that returns:System.Net.WebException: The remote server returned an error: (404) Not Found.
what went wrong? thanks
There are two possible scenarios here:
1: If you are building a client app (e.g. Console or WinForms) and want to access http://localhost using WebClient or HttpWebRequest without any intervening proxies, then bypassonlocal="True" should accomplish this. In other words, your app.config should look like this:
<defaultProxy>
<proxy
usesystemdefault="False"
bypassonlocal="True"
/>
</defaultProxy>
</system.net>
2: if, however, you're trying to get your ASP.NET app (running on http://localhost) to be able to correctly resolve URIs either with a proxy or without one, then you'll need to set up proxy info correctly in your web.config (or in machine.config so you won't have to change your app's web.config), so ASP.NET will know that you are running a proxy or not running one. Like this:
Home:
<defaultProxy>
<proxy
usesystemdefault="False"
bypassonlocal="True"
/>
</defaultProxy>
</system.net>
Work:
<defaultProxy>
<proxy
usesystemdefault="False"
proxyaddress="http://yourproxyserver:8080"
bypassonlocal="True"
/>
</defaultProxy>
</system.net>
It's also possible to use proxy auto-detection, to pick up settings from the registry, etc. but I've always shied away from those approaches for servers apps... too fragile.
BTW, if you find that things are configured correctly, and you still get the error, the first thing I'd recommend is to code up a quick test which manually sets the proxy before your WebClient/HttpWebRequest call, instead of relying on configuration to do it. Like this:
WebProxy proxyObject = new WebProxy("http://proxyserver:80/",true);
WebClient wc = new WebClient();
wc.Proxy = proxyObject;
string s = wc.DownloadString ("http://www.google.com");
If the requests don't go through your work proxy correctly even when you're using code, even if the proxy is correctly configured in your code, then the proxy itself may be the problem.
In WebClient to download data from local no issues but downloading from internet is problem so configure the following
In your Web.config add below lines and replace your Intenet proxy Address and port
<system.net>
<defaultProxy useDefaultCredentials="true" enabled="true">
<proxy usesystemdefault="False" proxyaddress="http://your proxy address:port" bypassonlocal="True" />
</defaultProxy>
<settings>
<servicePointManager expect100Continue="false" />
</settings> </system.net>
now your program logic work for downloading content from internet and public URLS.