Re: Anyone have a rule to detect "Dear xxx" in the body of the message where the "To:" address is xxx@domain?

"Grant Taylor via users" <[email protected]>
Newsgroups gmane.mail.spam.spamassassin.general
Message-ID <[email protected]>
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. . . .
smime.p7s (application/pkcs7-signature, 3.9 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.