I happened to be working in YafSendMailThreaded.cs this afternoon. I was pushing it pretty hard and experienced my first duplicate emails. I was studying bad email address handling by the YAF SendMail task. Very interesting, like bbobb said.
One thing I observed was when multiple emails occurred the mail records seemed to be entering yaf_mail with 1 SendTries attempt (rather than 0.) That shouldn't be possible if you look at the yaf_mail_create sql proc, but perhaps somehow simultaneous calls are made to LegacyDb.mail_create()? Multiple threads? I can't say. Another observation when the duplicates occurred was messages were leaving the yaf_mail table one at a time over several minutes rather than many at a time. I restarted YAF. Processing returned to normal and the dupes were gone.
Sorry I only have observations to report. One thing I did do which might be helpful was modify the yaf_mail_delete SQL proc so that the users of any mail items with two SendTries are placed in a "do-not-mail" lookup table to eliminate possible bad email address processing issues. As for the "do-not-mail" logic, I'm actually sending records to yaf_mail from outside of YAF, which is where I'm checking the do-not-mail status and not sending those to Yaf_mail. It was determined on this thread that bad addresses weren't the culprit in the duplicate emails, but after looking into bad email handling, if nothing else it will reduce processing. And the less a background task has to do is always better.
Thanks,
Dave
Originally Posted by: daveburke