-
Notifications
You must be signed in to change notification settings - Fork 53
Script: SchleuderResend
Samuel Plentz edited this page Sep 15, 2022
·
2 revisions
If you are working with schleuder mailing list, it's sometime painful when answering peoples to re-add manually all the x-resend: [email protected]
.
// Get the mail body (see https://github.com/thundernest/quicktext/wiki/Script:-GetMailBody)
text = await this.mQuicktext.get_script(["GetMailBody"])
var resentLines = text.match(/Resent: .*\n/g)
var fromLines = text.match(/From: .*\n/g)
var toLines = text.match(/To: .*\n/g)
var ccLines = text.match(/Cc: .*\n/g)
var headerLines = []
if (resentLines != null) { headerLines = headerLines.concat(resentLines) }
if (fromLines != null) { headerLines = headerLines.concat(fromLines[0].split(",")) }
if (toLines != null) { headerLines = headerLines.concat(toLines[0].split(",")) }
if (ccLines != null) { headerLines = headerLines.concat(ccLines[0].split(",")) }
var resentEmails = []
var elem
var email
for (elem in headerLines) {
if (headerLines[elem] == null) { continue };
// Match all possible email in the string
emails = headerLines[elem].match(/\S+@\S+\.\S+/g)
if (emails == null) { continue };
emails = emails.map(sanitizeMail)
for (email in emails) {
resentEmails.push("x-resend: ".concat(emails[email]))
}
}
return resentEmails.join("\n")
function sanitizeMail(value) {
return value.replace(/</g, '').replace(/>/g, '').replace(/"/g,'')
}
Let's say you want to answer this email:
On 18/02/2020 11:15, Toto Bar wrote:
> From: Toto Bar <[email protected]>
> To: [email protected]
> Cc:
> Date: Sun, 01 Sep 2019 16:12:03 +0200
> Sig: Good signature from XAEAOFJU24 Toto Bar <[email protected]>
> Enc: Encrypted
> Resent: Unencrypted to [email protected]
> Resent: Encrypted to [email protected]
>
>
> Real Body Blabla
>
If you execute the script, it will return:
x-resend: [email protected]
x-resend: [email protected]
x-resend: [email protected]
x-resend: [email protected]