I am trying to setup a Forgot Password page that will email the user a temporary password. If I set the to email to an internal address, it works, but if it is set to any external address it does not. I get a SmtpFailedRecipientException with a message of "Mailbox unavailable. The server response was: <[email protected]> No such user here". He is my code: using System; using System.Collections.Generic; using System.Net; using System.Net.Mail; using SC.TAS.OKTLE.Common.BaseClasses; using SC.TAS.OKTLE.Common.Interfaces; using SC.TAS.OKTLE.Common.Interfaces.Email; using SC.TAS.OKTLE.Common.RequestResponseObjects; namespace SC.TAS.OKTLE.Common.Utility { public class Emailer : IEmailer { private readonly SettingsReaderBase _settingsReader; private readonly ILogger _logger; public Emailer() { _settingsReader = DependencyResolver.SettingsReader; _logger = DependencyResolver.Logger; } #region IEmailer Members public ServiceResponse Send(string to, string subject, string body) { ServiceResponse response = new ServiceResponse(); SmtpClient mailClient = new SmtpClient(); try { NetworkCredential networkCredential = new NetworkCredential("[email protected]", "********", "oktledev.com"); mailClient.DeliveryMethod = SmtpDeliveryMethod.Network; mailClient.EnableSsl = false; mailClient.Host = "mail.oktledev.com"; mailClient.UseDefaultCredentials = false; mailClient.Credentials = networkCredential; mailClient.Send("[email protected]", "[email protected]", subject, body); } catch (SmtpException smtpException) { _logger.LogError(smtpException); response.ApplicationErrors = new List<string> { "There was an error sending the email." }; return response; } return response; } #endregion } } Please advise as I have tried suggestions in other post and have not found an answer. Thank you, Michael Wheeler
Hi Michael, You could compare your code with the sample code we offer in our Knowledge Base: http://support.Winhost.com/KB/a650/how-to-send-email-in-aspnet.aspx Try removing the DeliveryMethod and not pass the extra domain parameter in NetworkCredential.