2

Overview From our MVC web app we are sending emails. We send 2,000 each time, once per day.

We send the emails one at a time to Postmark to process and deliver.

The connection with Postmark is via SMTP which is setup in Web.Config:

 <mailSettings>
  <smtp deliveryMethod="Network" from="name@domain.com">
    <network host="smtp.postmarkapp.com" port="587" enableSsl="true" defaultCredentials="false" userName="username" password="password" />
  </smtp>
</mailSettings>

We're using Postal in our app for email templating, etc.

foreach(var user in users)
{
    var email = new Postal.Email;
    {
       EmailTo = user.Email,
       Subject = "Subject",
       //other email content
    };

    //Send email
    email.Send();
}

Our web app is on Azure in a Web App service.

The processing and sending is being done in a background method using Hangfire with no automatic retries.

Problem There is a small percentage (exact percentage not known) of recipients that are consistently receiving duplicates or triplicates of these emails each day. We haven't noticed a pattern with the ones receiving more than one (i.e. that they're from the same domain, etc.).

In our code, the email details and content are created in a loop and fired off one at a time. We've added logging in our code to verify that we're really only creating one email to the people receiving duplicate and triplicate emails.

We've talked to Postmark about any ideas they have. They said they didn't think it was them. I've looked in the headers of the emails via the Postmark UI and the duplicates have unique message Id's.

Question Are there things that can happen with the way emails are handled when lots of them are being fired off in short succession using SMTP in an MVC app? Is there a way to log what is actually being sent from the app/server?

amartin
  • 330
  • 2
  • 4
  • 17
  • Why not try to send all emails in one shot? They are different for each user? – Adlorem Dec 08 '20 at 20:17
  • @Adlorem yes, they're unique for each person – amartin Dec 08 '20 at 23:44
  • Do you have any response check if mail is sent trough provider or this is just fire and forget? – Adlorem Dec 09 '20 at 10:53
  • @Adlorem we're sending through Postmark, so we have lots of info about the emails we've sent to them to process and send. What Postmark is showing is consistent with what our customers are saying in cases where there are multiple copies of the emails. Postmark said the problem is not on their end, but I don't know how to verify that yet, aside from the logging in our code, which doesn't tell me what the built in SMTP service is doing – amartin Dec 09 '20 at 20:04
  • 1
    You could check sender IP in two duplicated emails. If they are different its on Postmark unless you have dedicated IP with them. – Adlorem Dec 10 '20 at 20:06

0 Answers0