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>
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.
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.
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>
This question already has answers here:
The SMTP server requires a secure connection or the client was not authenticated.
(3 answers)
Closed 8 years ago.
When I was setting up a recover forgot password using passwordrecovery control, I am getting this error.
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. hx9sm7431239pbc.68
And this is my code behind for the recover password:
<add name="Connection" connectionString="Data Source=USER-PC\SQLEXPRESS;Integrated Security=true;Initial Catalog=CarRental" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="notme#gmail.com">
<network host="smtp.gmail.com" port="25"/>
</smtp>
</mailSettings>
</system.net>
Hope someone can tell me what is wrong with my code. Thank you
If you are using asp.net 4.0, you need to set enableSsl to true.
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="notme#gmail.com">
<network host="smtp.gmail.com" port="25" enableSsl="true"="true"/>
</smtp>
</mailSettings>
</system.net>
Prior to 4.0, you will have to do this in code.
Add it on the OnSendingMail event.
SmtpClient client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.Host = "smtp.gmail.com";
client.Port = 587;
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.