Absolutely! It's relatively simple too, at the most basic level you do the following:
- Assign every email you send a unique id, in the email place a reference to a script on your server with the unique id. (e.g.
<img src="https://example.com/img?id=1 >
) - When
/img?id=N
is called have your code log theid
and then serve the image.
A more concrete example in PHP would look something like:
Mail Sender:
$img = '<img src="https://example.com/img.php?id=' . generate_email_id() . '">';
mail("test@example.com", "This is a test.", "Hello! I hope this test works!" . $img);
img.php:
log_email_by_id($_GET['id']);
header("Content-type: image/jpeg");
readfile("pixel.jpg");