Good day,
I have a MVC application that send out emails, everything works fine locally, however when deploy the code to Windows Server 2012 with IIS8 it throws error above. I have seen some answers with related postrs, however it doesnt seem to work for me. What I tried was this.UseDefaultCredentials = true; as suggested by many but doesnt work for me. Please see my code below.
public class EMMEmailService : SmtpClient
{
public string UserName { get; set; }
public EMMEmailService() :
base(ConfigurationManager.AppSettings["EmmEmailHost"], Int32.Parse(ConfigurationManager.AppSettings["EMMPort"]))
{
//Get values from web.config file:
this.UserName = ConfigurationManager.AppSettings["EMMUserName"];
this.EnableSsl = false;//Boolean.Parse(ConfigurationManager.AppSettings["EMMSsl"]);
//this.UseDefaultCredentials = false;
this.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["EMMUserName"], ConfigurationManager.AppSettings["EMMPassword"]);
}
}
and here is the config file
<!--Smptp Server (confirmations emails)-->
<add key="EMMUserName" value="business@xxxxxx"/>
<add key="EMMPassword" value="xxxxxxxxx"/>
<add key="EmmEmailHost" value="x.x.x.x"/>
<add key="EMMPort" value="25"/>
<add key="EMMSsl" value="true"/>
Please assist as I am stuck with this error.