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

Email code not working #8233


User avatar
0
nitinrpatel created

Hello, I Am Using ASP.NET MVC 5.x with AngularJS Verson. I am facing issue while i am sending test emails. Popup Shows that email sent successfully, but i didnot receive any email.Can you please help to where i have to change in code to send emails.


4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    Please check the application's log. There will be helpful information in the log.

  • User Avatar
    1
    smry created

    I had this issue and just assumed the code was there for looks but didnt actually work (Meaning the only thing it did was show "test email sent" but no backend code did anything)

    After maliming's comment I realized it wasnt just me.

    I started checking what the log said as he mentioned and log mentioned:

    INFO  [35   ] pNetCore.Cors.Infrastructure.CorsService - CORS policy execution successful.       
    INFO  [35   ] uthentication.JwtBearer.JwtBearerHandler - Successfully validated the token.
    INFO  [35   ] ft.AspNetCore.Routing.EndpointMiddleware - Executing endpoint 'companyName.Configuration.Host.HostSettingsAppService.SendTestEmail (companyName.Application)'
    INFO  [35   ] c.Infrastructure.ControllerActionInvoker - Route matched with {area = "app", action = "SendTestEmail", controller = "HostSettings"}. Executing controller action with signature System.Threading.Tasks.Task SendTestEmail(companyName.Configuration.Host.Dto.SendTestEmailInput) on controller companyName.Configuration.Host.HostSettingsAppService (companyName.Application).
    WARN  [35   ] Abp.Net.Mail.NullEmailSender             - USING NullEmailSender!
    DEBUG [35   ] Abp.Net.Mail.NullEmailSender             - SendEmailAsync:
    DEBUG [35   ] Abp.Net.Mail.NullEmailSender             - [email protected]
    DEBUG [35   ] Abp.Net.Mail.NullEmailSender             - 
    DEBUG [35   ] Abp.Net.Mail.NullEmailSender             - companyName test email
    DEBUG [35   ] Abp.Net.Mail.NullEmailSender             - This is a test email.
    INFO  [32   ] .Mvc.Infrastructure.ObjectResultExecutor - Executing ObjectResult, writing value of type 'Abp.Web.Models.AjaxResponse'.
    INFO  [32   ] c.Infrastructure.ControllerActionInvoker - Executed action companyName.Configuration.Host.HostSettingsAppService.SendTestEmail (companyName.Application) in 27.1706ms
    INFO  [32   ] ft.AspNetCore.Routing.EndpointMiddleware - Executed endpoint 'companyName.Configuration.Host.HostSettingsAppService.SendTestEmail (companyName.Application)'
    INFO  [32   ] Microsoft.AspNetCore.Hosting.Diagnostics - Request finished in 51.2509ms 200 application/json; charset=utf-8
    

    "USING NullEmailSender!" caught my eye and when I went searching the source, I came across this that solved my issue:

    if (DebugHelper.IsDebug)
        {
            //Disabling email sending in debug mode
            Configuration.ReplaceService<IEmailSender, NullEmailSender>(DependencyLifeStyle.Transient);
        }
    

    Edit: One additional intersting thing I noticed - You have to Save All in order to get the credentials to update, so after you input your SMTP credentials, Save All, THEN send test email - otherwise it tries to use the 127.0.0.0 credentials it originally has

  • User Avatar
    0
    maliming created
    Support Team

    @smry Thanks for the information.

  • User Avatar
    0
    nitinrpatel created

    Thank You @smry & @maliming I got solution and got test Email.