when i host my application in IIS server then it gives me thsi error The SMTP host was not found.
System.Net.Mail.SmtpException: The SMTP host was not found. —> System.Net.WebException: The remote name could not be resolved: ‘mail.corbissoft.com’ my code is this public static async Task SendScheduledEmailAsync(int clientId, string messageBody)
{
try
{
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient
{
Port = 587,
Host = “mail.corbissoft.com”,
EnableSsl = false,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(“[email protected]”, “123456789”),
DeliveryMethod = SmtpDeliveryMethod.Network
};
message.From = new MailAddress("[email protected]");
message.To.Add(new MailAddress(new data_StockTransferInfoModel().GetEmail(clientId, messageBody)));
message.Subject = "Test Email from ASP.NET Web API";
message.IsBodyHtml = true;
message.Body = messageBody;
await smtp.SendMailAsync(message);
}
catch (SmtpException smtpEx)
{
Log.Error(smtpEx, "SMTP error occurred while sending email: {ErrorMessage}", smtpEx.Message);
}
catch (Exception ex)
{
Log.Error(ex, "An error occurred while sending email: {ErrorMessage}", ex.Message);
}
} I tried all the possible sloution but i dont how to fix the error
i wan to slove the Problem this errror [ERR] SMTP error occurred while sending email: The SMTP host was not found.
System.Net.Mail.SmtpException: The SMTP host was not found. —> System.Net.WebException: The remote name could not be resolved: ‘mail.corbissoft.com’
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.ConnectAndHandshakeAsyncResult.GetConnection(Boolean synchronous)
at System.Net.Mail.SmtpConnection.BeginGetConnection(ServicePoint servicePoint, ContextAwareResult outerResult, AsyncCallback callback, Object state)
at System.Net.Mail.SmtpTransport.BeginGetConnection(ServicePoint servicePoint, ContextAwareResult outerResult, AsyncCallback callback, Object state)
— End of inner exception stack trace —
at System.Net.Mail.SmtpTransport.BeginGetConnection(ServicePoint servicePoint, ContextAwareResult outerResult, AsyncCallback callback, Object state)
at System.Net.Mail.SmtpClient.SendAsync(MailMessage message, Object userToken)
at System.Net.Mail.SmtpClient.SendMailAsync(MailMessage message)
at LuandaryWebAPI.HelperClass.WhatsAppMessages.d__4.MoveNext() in E:WEBAPI_CHMUNIR 29-04-24 backup (2)WEBAPI_CHMUNIRLuandaryWebAPIHelperClassWhatsAppMessages.cs:line 170
Daniel Zain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.