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

SMTP cannot send email out #3101


User avatar
0
fguo created

I am trying v4.0 (Core+Angular). On release mode, I set SMTP with the one on the same Web host server, and send test email successfully. However, the emails are always stuck in \mailroot\Queue, and ultimately into \mailroot\Badmail. I tried to test with several email addresses, but got same thing. The *.BAD files always contains same error message: "Delivery to the following recipients failed." :(

I tried to use SMTP on another server, but got "An internal error occurred during your request". The log text is: System.NotSupportedException: The SMTP server does not support authentication.

Any clue?

Thanks,


8 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Such problems generally occurs because of wrong SMTP configuration or a problem with SMTP server.

    We are using MailKit to send emails and mail sending code is fairly simple (<a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.MailKit/MailKitEmailSender.cs">https://github.com/aspnetboilerplate/as ... lSender.cs</a>). If you suspect that there is a bug inside the framework, can you just write a simple code to send email with your own configuration.

  • User Avatar
    0
    fguo created

    My SMTP server works with my other applications on IIS based on .NET 2,3,4. I use the same host name and port number on Administration > settings > Email(SMTP) page.

    I heard that the SmtpClient class in system.net.mail namespace is not available yet in .NET Core. Maybe this is the reason why the SMTP does not work on my Core+Angular version?

    I like to follow you to use MailKit, and I see the Abp.MailKit in .Core Dependencies. What should I set in Administration > settings > Email(SMTP) page to use MailKit? :?:

    Now, all email functions seem not working, e.g. email activation. Shall I do some configuration about MailKit? :?:

    Thanks,

  • User Avatar
    0
    alirizaadiyahsi created

    Hi,

    If you download lates aspnet zero core project, Mailkit enabled as default. So you don't need to do anything. If you manually upgraded the project, please check your project, if Abp.Mailkit dll is added in project.

    If everything is ok, then could you please try to use MailKit in a core project that is independent from aspnet zero core project. Check this for using MailKit: <a class="postlink" href="https://github.com/jstedfast/MailKit#using-mailkit">https://github.com/jstedfast/MailKit#using-mailkit</a>

  • User Avatar
    0
    fguo created

    I am using v4.0 from scratch, so I shouldn't do anything on Email(SMTP), right? I just tried to leave all settings blank, but I can not save the page. How do I reverse it back to the original settings? I remembered the original port setting is 25, and host name is some thing like 127.0.0.x. Can you tell me these original settings?

    I remembered, before I set SMTP, I tried "Send Test Email" and got "Internal Error".

    I will try MailKit as your example on my own modules, but now I need the user-email-activation works first.

    Thanks again for your prompt response!

  • User Avatar
    0
    fguo created

    I just tried to type something in Administration > settings > Email(SMTP) page to prevent from empty string in order to save the change. I got "Internal error" popup this time when I try to email activation. The MailKit seems handling the email but has issues around "authentication". See the log below:

    System.NotSupportedException: The SMTP server does not support authentication.

    at MailKit.Net.Smtp.SmtpClient.Authenticate(Encoding encoding, ICredentials credentials, CancellationToken cancellationToken)

    at MailKit.MailService.Authenticate(String userName, String password, CancellationToken cancellationToken)

    at Abp.MailKit.DefaultMailKitSmtpBuilder.ConfigureClient(SmtpClient client)

    at Abp.MailKit.DefaultMailKitSmtpBuilder.Build()

    at Abp.MailKit.MailKitEmailSender.BuildSmtpClient()

    at Abp.MailKit.MailKitEmailSender.<SendAsync>d__2.MoveNext()

    --- End of stack trace from previous location where exception was thrown ---

    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

    at Abp.Net.Mail.EmailSenderBase.<SendAsync>d__4.MoveNext()

    --- End of stack trace from previous location where exception was thrown ---

    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

    at SNet.Configuration.SettingsAppServiceBase.<SendTestEmail>d__2.MoveNext()

    --- End of stack trace from previous location where exception was thrown ---

    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__27.MoveNext()

    --- End of stack trace from previous location where exception was thrown ---

    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__25.MoveNext()

  • User Avatar
    0
    hikalkan created
    Support Team

    As I answered on this post (#3072@0802a55c-7416-4c0e-a699-9e23539dadfb) these problems are related to SMTP server or email settings. AspNet Zero's email sending code is very simple and tested.

    Default template comes with a few default settings but surely you must set correct settings for your own SMTP server to be able to send emails. As I suggested, please create an independent simple console application and just try to send emails. If you able to send, then apply same settings for AspNet Zero. If it works in your console app but not works for aspnet zero then share us your code and aspnet zero settings so we can help.

  • User Avatar
    0
    tankods created

    Hi. I am using Angular 9 and .Net Core 3.1. Not work the method SendAsync from Abp.Net.Mail. Is it working for .Net Core 3.1 now, or do I need to use the "Abp.MailKit" for it?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @tankods

    Could you create a new issue including the details of the problem you are facing ?

    Thanks,