It sends the emails locally, and I can confirm them and then everything is just fine and dandy. After deployment, it still gives me the "please check your email" screen, but the email isn't actually sending. I did open up port 587 manually on IIS thinking that maybe this was blocking it, but identifying the actual root of the cause is escaping me. Apologies if this has been asked before, I'm new to this framework and am trying not to ask stupid questions. I sincerely appreciate any help! Also, code that I included is where I assume it's coming from but I can't really be sure. I appreciate it. EDIT I found that it is in fact still keeping the correct email so I'm assuming something on the server could be blocking this?
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.Extensions.Options;
using SendGrid;
using SendGrid.Helpers.Mail;
using System.Threading.Tasks;
namespace O3is_v1.Models
{
public class SendGridEmailSender : IEmailSender
{
public SendGridEmailSender(
IOptions<SendGridEmailSenderOptions> options
)
{
this.Options = options.Value;
}
public SendGridEmailSenderOptions Options { get; set; }
public async Task SendEmailAsync(
string email,
string subject,
string message)
{
await Execute(Options.ApiKey, subject, message, email);
}
private async Task<Response> Execute(
string apiKey,
string subject,
string message,
string email)
{
var client = new SendGridClient(apiKey);
var msg = new SendGridMessage()
{
From = new EmailAddress(Options.SenderEmail, Options.SenderName),
Subject = subject,
PlainTextContent = message,
HtmlContent = message
};
msg.AddTo(new EmailAddress(email));
// disable tracking settings
// ref.: https://sendgrid.com/docs/User_Guide/Settings/tracking.html
msg.SetClickTracking(false, false);
msg.SetOpenTracking(false);
msg.SetGoogleAnalytics(false);
msg.SetSubscriptionTracking(false);
return await client.SendEmailAsync(msg);
}
}
}