Problem: You want to send emal notifications with file attachments from your Jira, however, your email server doesn't handle mails where attachments exceed specific size. You want to email them unless the total size doesn't exceed specific value.
Solution: Use the following template example as reference
On line 1 we define a variable $totalLength where we store the total size of specific Jira issue attachments (in line 2).
Then on line 6 we compare the $totalLength against the maximum possible size (10000000 or 10MB)