tell application "Mail"
activate
set acntList to accounts as list
repeat with anAcnt in acntList
set move deleted messages to trash of anAcnt to true
set empty trash frequency of anAcnt to -1 -- never
set empty sent messages frequency of anAcnt to -1 -- never
end repeat
end tell
I tested this code and I was sure that the preference changes were persistent.
I have now tested this again, a few years later, and found that any changes made to Mail's preferences via AppleScript are temporary. There is a really good reason for these changes to be permanent, so ...
Plan C
I've written code to read and write the preference file, "com.apple.mail.plist", directly. But, if Apple changes the preference file format, my code will break, so, this may not be a good idea. So ...
Plan D
Every application that has preference modifying commands should also have an 'update preferences' command. I'll wait until hell freezes over and use that.
Plan E
(I'm out of plans.)