Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4007814
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:40:39+00:00 2026-05-20T08:40:39+00:00

I want to send email to my app users ensuring that every email is

  • 0

I want to send email to my app users ensuring that every email is sent only once.
I will be recording the email transmission in a database.
If I use this order of operations:

  1. Insert into database
  2. Send email
  3. Commit

There is a chance that script times out just after sending the email (step #2) and before doing the commit (step #3). In that case the change in step #1 will not be committed and email sending job won’t be able to know that the email was successfully sent last time so the same email will be sent again.

Is there a way out or do I have to live with occasional duplicate emails?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:40:40+00:00Added an answer on May 20, 2026 at 8:40 am

    Just got some time to think over my own question. Here is what I think now:

    The email sending steps in question were:

    1. Insert into database
    2. Send email
    3. Commit

    Email cannot be made transactional because the step #2 (above) is not part of the transaction even though it is done while the transaction is active.

    These steps can help ensure that any failed email-sending attempts is retried but cannot guarantee that an email is not sent more than once. This situation could only be improved if the email sending engine is transaction-aware. Such an engine would (atleast) do the following:

    1. Accept email job submission but don’t send the email until the commit is performed
    2. Make the commit fail if the email is not sent.
    3. Cancel the submitted job if the transaction is rolled-back

    I am not aware of any such email server.

    Nishant, in his answer suggested following steps:

    1. Insert the data before sending the mail. And set status to sending
    2. Send the mail
    3. based on the result in step (2), update the row either failed or sent_successfully.

    These steps also cannot ensure duplicate sending of email due to script timeout for the same reason as noted above.

    So far, I think, I will just have to live with occasional duplicate emails.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently running a web-app that will send emails to users when they sign-up,
I want to send the same email to all of the users that have
I'm writing an app which allows users to send out a text-only email to
I want to create a newsletter app and users will naturally have to confirm
I am building an application which will send status requests to users (via email
I'm creating a newsletter feature that will allow users to send emails. Since there
I've installed this django-contact-form app. When I want to send an email to my
I want my app to be able to send an email with attachment to
I want to send email that contains form as a body from my mobile
Say you want to schedule recurring tasks, such as: Send email every wednesday at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.