Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

_emailSender stopped sending #11493


User avatar
0
admin@SYNTAQ created

.Net Core, MVC Jquery, 11.2

Hi,

Email Sender has stopped sending emails. we have confirmed the account is correct and receive no errors back from the SendTestEmail function. It does not work in dev, test or Prod environments. If we add conventioanl .net code to send the email message then the email does get sent. You can see the sample working email code in the second code block.

Is there any configuration that can disable the email sender accidently? Can you suggest any reason the _emailsender my stop working? We have been using it with no issues previously. We have triple checked the account details on both configurations. There are no apparent changes we can identify between it working and not working

    // DOES NOT SEND EMAIL MESSAGE ////////////////////////////////////////////////////////////////////

    public async Task SendTestEmail(SendTestEmailInput input)
    {
        try
        {
            await _emailSender.SendAsync(
                input.EmailAddress,
                L("TestEmail_Subject"),
                L("TestEmail_Body")
            );
        }
        catch (Exception e)
        {
            throw new UserFriendlyException("An error was encountered while sending an email. " + e.Message, e);
        }
    }  


        // THIS DOES SEND THE EMAIL ////////////////////////////////////////////////////////////////////
        public async Task SendTestEmail(SendTestEmailInput input)
        {
            try
            {
                MailMessage message = new MailMessage();
                SmtpClient smtp = new SmtpClient();
                message.From = new MailAddress("xxxxxxxxxxxxx");
                message.To.Add(new MailAddress("xxxxxxxxxxxxx"));

                message.Subject = "Test";
                message.IsBodyHtml = true; //to make message body as html  
                message.Body = "Hello World";
 
                MailMessage mail = new MailMessage
                {
                    IsBodyHtml = true
                };
                
                smtp.Port = 25;
                smtp.Host = "in-v3.mailjet.com"; //for gmail host  
                smtp.EnableSsl = true;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = new NetworkCredential("xxxxxxxxxxxxxx", "xxxxxxxxxxxxxx");

                smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtp.Send(message);

            }
            catch (Exception e)
            {
                throw new UserFriendlyException("An error was encountered while sending an email. " + e.Message, e);
            }
        }

1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    In the Core module class, there is a code block like below;

    This only write email content to log file instead of sending an email in debug mode. Could you check your log files to see if email content is written to the log file ? You might be publishing your app in debug mode in that case. You can switch to release mode when publishing your app to solve this problem.