Email Sent callback to script
Problem reported by Paul White - 4/6/2026 at 1:29 PM
Not A Problem
I have built a email / newsletter application that allows my client to manage campaigns and their lists.  When they do a send I have the system setup to queue these emails to a database.  Then as script picks up a few emails each minute passes them on to smartermail, which then sends them out. This helps to avoid any delivery spikes which many of the major ESPs (yahoo, gmail, ext ) would consider spam.  The problem we are running into is accurate tracking of the bots.  We need to be able to track when an open or link click is a real person rather than a bot.  

For what I have read the most accurate way is to track when the email was sent / delivered, and compare that to the open / click datetime.   If the open / click happens within a few seconds of delivery that is often a bot or filter scanning the message.  Everything else could safely be considered organic.  I can track the datetime I pass the email from my quote to smartermail for delivery. But sometimes that email might sit in the spool for a a while.  
What I need is a way for smartermail to give me a callback to my server, that they have successfully delivered the message.  Is there anyway to do this?
Douglas Foster Replied
Why not have all links point to your webserver, so that links are logged by your IIS?  Then use redirects if you need to link to a customer website.
Paul White Replied
We already do that.  All links are rewritten back to our website for tracking then they are redirected to the intended URL.  What we need is the ability to track the second smartermail actually pulls the email from its spool and sends it.  Simply tracking when the email is pulled from our Queue is not accurate enough since depending on the load on the mail server, smartermail could park emails into the spool for several seconds or several minutes.  Scanners and filters tend to process emails received within seconds of being received.  Thats why I need to know the exact instead smartermail actually delivers the message.
Paul White Replied
What I am looking to do is pass in to smartermail some kind of header the specifies a URL they should callback to once the message has been delivered from the spool.  Doesn't matter if its not opened, or if the receiving server throws it to spam. I am just concerned with tracking the exact date time smartermail deliver's the message, so I can track the delay between delivery and any links being crawled ( by scanners or filters ) to help me get better data on organic opens vs the bots.
Douglas Foster Replied
Delivery logs will get you close, but I have some evidence that the timestamp may indicate when the log is written rather than when the delivery completes.

You might do better using an outbound gateway that is dedicated to these messages, and Postfix might offer more customization options.

Sébastien Riccio Replied
Not sure it will help you achieve what you're trying to do, and I never testing this, but you might use system Events.

For exemple add an Event of type "Mail", with condition "Message sent"


With conditions that matches these particular mails you're sending and with action "Web hook"


I suppose you could add some header to your mails from your app and use this header value in the webhook call to your app, to track when mails are sent.

Again this isn't something I tested myself so no guarantees it will fit your needs.

Kind regards
Sébastien Riccio
System & Network Admin

Zach Sylvester Replied
Employee Post

Hi Paul,

Thanks for the question.

A better option may be to filter by user agent, though that is not a guaranteed solution since the user agent can be changed.

If your goal is to track delivery, there are a couple of approaches you could take. One option is to scrape the logs, which would be the more manual method. Another option is to use the API to track when a message leaves the spool.

I hope that helps.

Regards,

Zach Sylvester

Software Developer
SmarterTools Inc.
Douglas Foster Replied
It occurs to me that what you call a Bot is what the rest of us call an email filtering service that does malicious link checking and URL rewrite to provide time-of-click protection.   They are the good guys, even if you find them inconvenient.

It sounds from the other comments that you may already have what you want, but any webhook is going to add latency that may be not significantly different than the delivery log buffering latency   

It seems like the time-based approach may be over-engineering the problem.   Click protection is in all the major products, so if you can identify the products, you should be able to separate the automated checks from the user clicks.   There are a bunch of clues available to you:
  • IIS Data: User agent, Reverse IP name, and Refer-From host, as Zack suggested
  • DMARC Aggregate Report data:  Reporting entity name and reporting domain name
  • Delivery log data:  MX DNS name, Helo name, and Reverse DNS name
I expect link checks will have a unique user agent and a host name that points to a major product, while the real clicks will have a refer-by name of the products server.  Then this is validated by comparing to the other data sources.

Paul White Replied
Hey Douglas, Yes I am calling what everyone calls filters a bot : )
I will try some of the other comments to see if that gives a solution
Reverse IP name is not very effective. I already wrote a script to pull that info for all IPs in my logs and a good portion of them come back empty.  User Agent could be a temporary way to filter.  As I do see 90% of the clicks are all the same user agent, which I suspect means its the same filtering tech, but its not exactly a unique Useragent. 

mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/144.0.0.0 safari/537.36

Thanks everyone for the suggestions!

Reply to Thread

Enter the verification text