Open Closed

how to avoid sending the email confirmation email twice #8676


User avatar
0
LiSong created
  • ABP Framework version: v9.X.X
  • UI Type: Angular / MVC / Blazor WASM / Blazor Server
  • Database System: SQL Server
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes/no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

When an user created a new account, the confirm your email page shows, and there is a Verify button, before they click the button, a confirmation email was sent to their inbox, and if the users click the Verifiy button again, they receive another same email again. is there a way to avoid this? for instance, wait they click the Verify button before sending the first email; or check the email sent log(is there logs for this), if the same email has been sent, prevent the system to send it twice. any suggestions?


10 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    In the latest version, the button will be hidden to prevent multiple send email.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    If you want to check on the server side, you can try to override the SendEmailConfirmationTokenAsync method.

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(AccountAppService))]
    public class MyAccountAppService : AccountAppService
    {
        protected override async Task SendEmailConfirmationTokenAsync(IdentityUser user,
            string applicationName,
            string returnUrl,
            string returnUrlHash)
        {
            var isEmailSent = // get from cache or db.
            if(isEmailSent){
                throw new UserfriendlyException("...")
            }else{
                var confirmationToken = await UserManager.GenerateEmailConfirmationTokenAsync(user);
                await AccountEmailer.SendEmailConfirmationLinkAsync(user, confirmationToken, applicationName, returnUrl, returnUrlHash);
                // add confirmationToken to cache or db
            }
            
        }
    }
    
  • User Avatar
    0
    LiSong created

    In the latest version, the button will be hidden to prevent multiple send email.

    Which version?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi, 9.0.3

  • User Avatar
    0
    LiSong created

    I upgraded to 9.0.3, it's still the same, the issue here is that the system automatically sends the first email, then this page loads and with this verifiy button. The user clicks the button, and at that point, a second email will be sent. Is there a way to detect that the system has sent the first email and prevent the button from being displayed?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I can't reproduce the problem.

    Did you override the page and JS file?

    Is there a way to detect that the system has sent the first email and prevent the button from being displayed?

    See https://abp.io/support/questions/8676/how-to-avoid-sending-the-email-confirmation-email-twice#answer-3a1798e4-ae13-2b5c-d6b5-b6226abd84f1

  • User Avatar
    0
    LiSong created

    no, I didn't override the page

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Can you reproduce it in a new project?

    abp new Testapp

  • User Avatar
    0
    LiSong created

    yes, the same

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    yes, the same

    please share the project with me. thanks. shiwei.liang@volosoft.com

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 20, 2025, 18:00