I never cared knowing more about the error messages.
Looks like there is a lot to learn from it.
Here is the complete error message.
System.Net.Mail.SmtpException: Failure sending mail.
---> System.Net.WebException: Unable to connect to the remote server
---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 111.111.11.11:25
Ok, that means that SMTP may not be enabled on your email server. I would show this error to your administrators as they could troubleshoot the problem. If memory serves me correctly, most email servers have SMTP relaying disabled. You have to turn it on
intentionally and allow certain machines.
What you're seeing here is best practice. We want to modify settings in the web.config file, not have to hard-code variables throughout the application. That's why we put SQL connection strings and mail settings inside the web config. That way we don't re-write
our code just to change a setting.
krishna.bb
Member
128 Points
111 Posts
Error sending emails
Nov 19, 2012 07:12 PM|LINK
Hello,
I tried the following code to send emails from my web application.
We use Lotus notes as a email application.
Thank you!
try { MailMessage message = new MailMessage(); message.To.Add("xyz@myclient.com"); message.Subject = "Your account details"; message.From = new MailAddress("abc@myclient.com"); message.Body = "Bonjour"; System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("myclient.com"); smtp.Send(message); } catch (Exception ex) { }I received the following error message:
Failure sending mail.
Krishna
bbcompent1
All-Star
32978 Points
8502 Posts
Moderator
Re: Error sending emails
Nov 19, 2012 07:24 PM|LINK
What error are you getting? If its a 550, you have to see your lotus notes admin to have SMTP relaying turned on.
krishna.bb
Member
128 Points
111 Posts
Re: Error sending emails
Nov 19, 2012 07:40 PM|LINK
Hello bbcompent1,
Thanks for your response.
I have received:
Failure sending mail.
Krishna
bbcompent1
All-Star
32978 Points
8502 Posts
Moderator
Re: Error sending emails
Nov 19, 2012 07:47 PM|LINK
Ok, rewrite your catch to be like this:
catch (Exception ex) { Response.Write(ex.ToString()); }That will show what the error really is.
krishna.bb
Member
128 Points
111 Posts
Re: Error sending emails
Nov 19, 2012 07:59 PM|LINK
Thanks for your suggestion.
I never cared knowing more about the error messages.
Looks like there is a lot to learn from it.
Here is the complete error message.
System.Net.Mail.SmtpException: Failure sending mail.
---> System.Net.WebException: Unable to connect to the remote server
---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 111.111.11.11:25
Thanks again!
Krishna
bbcompent1
All-Star
32978 Points
8502 Posts
Moderator
Re: Error sending emails
Nov 19, 2012 08:03 PM|LINK
Ok, that means that SMTP may not be enabled on your email server. I would show this error to your administrators as they could troubleshoot the problem. If memory serves me correctly, most email servers have SMTP relaying disabled. You have to turn it on intentionally and allow certain machines.
krishna.bb
Member
128 Points
111 Posts
Re: Error sending emails
Nov 19, 2012 08:29 PM|LINK
Thanks for your suggestions.
Reaching my administrator is a tough task and it takes long time (usually weeks).
But I will give it a shot.
I am not sure if the smtp server that coded is correct though, can you please tell me a way to find out my SMTP Server?
Thank you!
Krishna
bbcompent1
All-Star
32978 Points
8502 Posts
Moderator
Re: Error sending emails
Nov 20, 2012 01:25 PM|LINK
Unfortunately, I have no way of knowing what your SMTP server would be, your IT staff can provide that to you however.
climm2
Member
208 Points
72 Posts
Re: Error sending emails
Nov 20, 2012 09:41 PM|LINK
I do not know about Lotus but for win server's SMTP
At web config..
add,
<configuration>
<system.net>
<mailSettings>
<smtp>
<network host="(your server name)" port="25" userName="(id)" password="(password)"/>
</smtp>
</mailSettings>
</system.net>
bbcompent1
All-Star
32978 Points
8502 Posts
Moderator
Re: Error sending emails
Nov 21, 2012 11:00 AM|LINK
What you're seeing here is best practice. We want to modify settings in the web.config file, not have to hard-code variables throughout the application. That's why we put SQL connection strings and mail settings inside the web config. That way we don't re-write our code just to change a setting.