Possibility to remove email footer in script runner mail handler

Christoph Schmitz May 13, 2020


is it possible to remove the email footer or signature within a script runner mailhandler? If so, how would you achieve this feature?

Yours Christoph

2 answers

1 accepted

0 votes
Answer accepted

Hi @Christoph Schmitz 

I tried the same with the email history and wanted to cut that off. However, this is had to be done by some string processing and looking for keywords like "From: " and it is not the best working solution. But if the footer and signature is always looking similar you can try to  search the mail body for keywords and cut it off.

What I also did was to remove the small icons from the signatures (<5kb) from the issues attachments. Usually you only want to have real attachments form an email in the issue and not those small icons. I did that by removing them directly from the issue in the mail handler script.

Christoph Schmitz May 14, 2020

Hi @Jonas Moehringer - ij-solutions ,

have you got some code snippets? I have no idea how to remove such things. Lookd up some RegEx but have also not a real idea of how this might works.


Hi @Christoph Schmitz

sure, here is an example of how the remove everything from the body starting from string "From: ":

if(body.toString().indexOf("From: ")!=-1){
if(body.toString().indexOf("From: ")!=0){
body = body.toString().substring(0, body.toString().indexOf("From: "))

It also considers that "From: " can't be at the beginning of the body because then nothing would be left of the body.

Afterwards, this body can be set as description. I am not an expert with regEx but there might be some nice solutions with regEx as well to cover more different email contents.

Christoph Schmitz May 20, 2020

Hello @Jonas Moehringer - ij-solutions

thanks for your example. I've already implemented another workaround where I used the split() method to cut the mail in 2 parts and only used the first one in my description.


Since our signature is static this works out for me.

Just one more question, do you have any idea / solution how to add the mail also to the attachment section of an issue so people can watch the original mail or store it?

Thanks in advance

Hi @Christoph Schmitz

ok, if your signature is always the same or similar you can use the split approach as well.

Regarding your question I can say that we had such requests from users as well but I didn't find any solution to implement something like that. Maybe you can write the email contents to a file on the server and then attach it to the issue, but I never did something like that. We just told our users that this is not possible ;)

Suggest an answer

Log in or Sign up to answer