Hi Benny and friends,

I’ve been thinking about whether there’d be an easy way for you to add conditional domain-based image loading, without doing a bunch of UI work for a feature that (admittedly) has limited appeal.

How about this:

1. define a new advanced preference: `defaults write com.freron.MailMate MmExternalUriApprover -string /path/to/uriapprover` 2. If this is set, MailMate would run this program when displaying an HTML email. It would send the program each image URL on stdin, and expect to get back the strings `allow` or `deny`. 3. MailMate would use this information to decide whether to display each external image.

I would write my own `uriapprover` script. A simple version might look like this:

```perl
#!/usr/bin/env perl

use Modern::Perl;
use Text::Glob 'glob_to_regex_string';
use URI;

my @allowed = qw(
    *.slack.com
    *.amazon.com
    *.postmark.com
);

my $allowed = join('|', map(glob_to_regex_string($_), @allowed));
sub allowed { eval { return URI->new($_)->host =~ m/($allowed)/o } }
while (<>) { say allowed($_) ? "allow" : "deny" }
```

Everyone else could ignore this feature.

What do you think?
-sam
_______________________________________________
mailmate mailing list
[email protected]
https://lists.freron.com/listinfo/mailmate

Reply via email to