0

I'm having trouble implementing an MVC project, specifically the forgot password functionality. When I debug in localhost, everything works as it should, but when I push the project up to my production server, no email ever gets to my account when I do a forgot password request.

I'm using the following code to send my email:

public class EmailService : IIdentityMessageService
{
    public Task SendAsync(IdentityMessage message)
    {
        var client = new SmtpClient();
        var mail = new MailMessage();
        mail.IsBodyHtml = true;
        mail.To.Add(message.Destination);
        mail.Subject = message.Subject;
        mail.Body = message.Body;
        client.SendMailAsync(mail);
        return Task.FromResult(0);
    }
}

And in my web.config, I have the following mail setting:

<system.net>
    <mailSettings>
      <smtp deliveryMethod="Network" from="resetpassword@xxxxxxx.com">
        <network host="xxxxxxxx" password="xxxxxxx" port="2500" userName="admin@xxxxxx.com" />
      </smtp>
    </mailSettings>
  </system.net>

I'm getting 200s when I look at the http calls in Fiddler, so to apparent error is being thrown. Is this enough info to speculate what I'm missing here?

Thanks.

Rex_C
  • 2,436
  • 7
  • 32
  • 54
  • Something is wrong with either your production SMTP connection settings or there's some network issue at play (firewall, spam filter, etc.) that's causing the issue. Based on what you've provided, it's impossible to say. – Chris Pratt Feb 03 '16 at 17:47
  • Is that port open? Does the email server have a log? – Jasen Feb 03 '16 at 17:47
  • I'll look into answers for these questions and update my post. – Rex_C Feb 03 '16 at 17:50
  • Is port 2500 correct? It is usually 25 or 587...If 2500 is correct, I would wager that the server firewall is blocking the outbound communication. – Tommy Feb 03 '16 at 18:05
  • The port is correct as far as I know, I use the web.config setting for a site related to this one and it works over there, so I'm assuming it is the correct port. – Rex_C Feb 03 '16 at 18:08
  • Whats frustrating me now is that I pushed the project up to a development site on the same server and it works fine. On the server, what settings should I be looking at to see if something is set wrong. – Rex_C Feb 03 '16 at 18:48
  • Check this please, https://stackoverflow.com/questions/27140402/why-does-smtp-via-gmail-work-locally-but-not-on-my-production-server – ismail tokmak Feb 16 '18 at 10:29

0 Answers0