On 7/18/24 15:58, Mark London wrote:
I asked ChatGPT how to test for a "Dear 'username'".  After a bit of work, I got working code.

Okay.

ChatGPT knows perl.

I question the value of "knows" as in knowledge of Perl.

I already had a Perl file EvalTests.pm file with customized Perl eval functions, so I threw it in there.  Otherwise, you'll need to create your own file with the proper headers.

sub check_body_for_username {
     my ($self, $permsgstatus) = @_;

     my $to = $permsgstatus->get('To:addr');
     return 0 unless $to;

     my ($username) = $to =~ /([^@]+)/;
     return 0 unless $username;

     # Check if the username is in the body of the email
     my $body = $permsgstatus->get_decoded_stripped_body_text_array();
     foreach my $line (@$body) {
         if ($line =~ /^(Dear|Hi|Hello) \Q$username\E\b/i) {
             return 1;
         }
     }
     return 0;
}

header DEAR_USERNAME    eval:check_body_for_username()

Very interesting.

I'll have to find a stick to poke this with and some time to do the poking.

Thank you for sharing.



--
Grant. . . .

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to