Issues with asp.net smtp email sending - asp.net

This is the error I get
No connection could be made because the target machine actively
refused it 127.0.0.1:25
here is my web.config snippet:
<mailSettings>
<smtp from="local#local.com">
<network host="localhost" port="25"/>
</smtp>
</mailSettings>
I (think) I have setup my smtp server through IIS. I went into the IIS Manager tool set
e-mail address to:local#local.com
SMTP Server: localhost
Port: 25
Authentication Settings : Not required
By doing all of this, am I theoretically setting up my web application to send email from the localhost? not sure why I am getting that error?
Thanks!

Related

Sending Email in Asp.net by private email

I'm trying to send email from my website i have these settings in my webconfig
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="info#thtsa.com">
<network host="smtp.privateemail.com" port="587" enableSsl="true" defaultCredentials="false" userName="info#thtsa.com" password="*****" />
</smtp>
</mailSettings>
</system.net>
but this exception
InnerException = {"The remote name could not be resolved: 'info#thtsa.com'"}
This issue comes when your code is not able to access your mail server. Please check if your server where your application is installed has access to your email server. You may try to ping to email server from your application server.
Additionally, you can try to use IP of smtp server instead of mail server name.

Amazon SES, The SMTP server requires a secure connection or the client was not authenticated

It was working fine when tested on the local SMTP but when deployed over the Amazon web server getting the following exception.
The SMTP server requires a secure connection or the client was not authenticated.The server response was: Authentication required
After going through so many blogs and posts it seems I should complete two steps to make it work.
enableSsl="true" in webconfig
second to install certificate on the app in IIS, we didn't buy the certificate so for testing I do the same as per the Scott Gu
Enabling SSL on IIS 7.0
My web config entry is as below
<smtp deliveryMethod="Network" from="behindthecurtain#empowher.com">
<network host="email-smtp.us-east-1.amazonaws.com" userName="xxxx" password="xxxx" port="587"
defaultCredentials="false" enableSsl="true"/>
</smtp>
So what else we can do to make it working ? guys any idea I'm totally stuck as you guess.

Sending mails not working in production environment - same settings

On my website i send e-mails. My situation is these mails are being sent when using my local development machine, and not on my production environment.
The web.config is the same on both sites:
<system.net>
<mailSettings>
<smtp from="info#domain.dk" deliveryMethod="Network">
<network host="mail.domain.dk" userName="info#domain.dk" password="mypassword" port="26"></network>
</smtp>
</mailSettings>
</system.net>
In my code, I send it like this:
SmtpClient client = new SmtpClient();
client.Send(mail);
I have no idea how to debug this problem, as it is the exactly same code on both production and development.
Any ideas on how to start debugging / solving the problem?
EDIT:
I managed to get a log from the server. Error is:
2012-11-01 20:41:58,383 [11] FATAL GKBusiness.Managers.MailManager [(null)] - Email exception: Mailbox unavailable. The server response was: Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
Hmm
My situation is these mails are being sent when using my local development machine, and not on my production environment.
<network host=..... port="26">
If you are in a shared hosting environment, it's likely that ASP.Net is set to Medium Trust - and if so, SMTP is restricted to port 25.
It will work in your local environment because ASP.Net is set to Full Trust (in local/VS dev).

reading smtp port from IIS settings

In my web.config file I have specified settings for sending mail. In particular I have these settings:
<system.net>
<mailSettings>
<smtp>
<network host="smtp.example.com" port="25" userName="user" password="pass"/>
</smtp>
</mailSettings>
</system.net>
Now the problem is that my isp suddently (without warning of course) have decided to block port 25 meaning I have to change to port 26 in my development envoiremnet. I belive the best way would be to change to port 26 in the IIS manager (this way I do not need to change anything when publishing my webapp to the remote server).
But how do I tell my asp.net webapp to use the default IIS setting?
check port no 587 its also use for smtp because most of ISP and web hoster block port 25 for security reason.

asp.net - how to make use of 2 or more email servers for failsafe

I have code that relies heavily on email notification. In my web.config I am able to specify an smtp server like this:
<system.net>
<mailSettings>
<smtp from="myaccount#mydomain.com">
<network host="mail.mydomain.com" port="25" userName="myusername" password="mypassword" defaultCredentials="true"/>
</smtp>
</mailSettings>
</system.net>
This is acceptable, but I would like to implement 2 or 3 exchange servers here in the event that (for what ever reason) smtp server 1 goes offline, I need a backup option.
Is there any quick / built in way to achieve this fail safe in .net, or is there a trusted manual way to implement this. My existing send mesage code looks like this (but watered down):
MailMessage message = new MailMessage();
SmtpClient client = new SmtpClient();
client.Send(message);
Notice its pulling the host directly from the configuration.
Any ideas what is best practice here for this scenario?
<network host="localhost" port=...
and configure the local SMTP transport to relay to your rendundant servers.
that way you won't loose emails because of transient network problems (the local MTA will just hold on to them).
There's an SmtpClient constructor that takes a host name and port. You could have a list of servers, try send the mail and if the server is unavailable it will throw an exception which you catch and retry with other server from the list.

Resources