Python Forum
Remove Email Signature - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Remove Email Signature (/thread-17822.html)



Remove Email Signature - NewBeie - Apr-25-2019

Hi,

I have this text of emails and their signature"

Quote:Good Morning

This is the first email block.


Vriendelike groete/ Kind regards

User One

Direct tel: 021 000 0000 | Email:
[email protected]






From: Test Emais [mailto:[email protected]]

Sent: 28 March 2019 11:00 AM
To: User One;[email protected];
Subject: Testing Subject




Dear Mr


Please note that we are testing this service

Service request number: TEST123 

When you contacted us: 2019-03-2810:15 AM 

Testing this

Testing it here

ok that's enough

Typing


Kind regards

The Typist


E-Mail: typist@User.co.za

Contact Number: 111 555 9988

Fax Number: 000 111 1234



The content of this email is confidential and intended for the addressee only. If it was sent to you in error, please notify the sender immediately and delete the email.

I would like to go through the text and remove the signature, but the code should be flexible for any text of this nature. As soon as there's "King Regards or Vriendelike groete" it should see that that's a signature, maybe preceded by '\n'. I don't know if there's Library out there or Regex, I've been trying to playing around with it but succeeding.

Quote:Good Morning

This is the first email block.


From: Test Emais [mailto:[email protected]]

Sent: 28 March 2019 11:00 AM
To: User One;[email protected];
Subject: Testing Subject




Dear Mr


Please note that we are testing this service

Service request number: TESTING123

When you contacted us: 2019-03-2810:15 AM 

Testing this

Testing it here

ok that's enough

Typing



RE: Remove Email Signature - Larz60+ - Apr-25-2019

What have you tried so far?


RE: Remove Email Signature - NewBeie - Apr-29-2019

Hi,

Thank you for the response, I actually have a pattern already,
pattern = re.compile(r'[Kk]ind [Rr]egards|[Vv]riendelike [Gg]roete/|[Vv]riendelike [Gg]roete|[Bb]est [Rr]egards| [Bb]est [Rr]egards| [Yy]ours [Ss]incerely| \n [Rr]egards')
But it only takes out the first part of the signature

My question was more on the entire Signature, one of them include their names and numbers after 'Kind Regards':
Quote:Vriendelike groete/ Kind regards

Badu Thusong

Direct tel: 021 974 7313 | Email:
[email protected]

But others doesn't, it's just this:
Quote:Kind regards

Agriculture Contact Centre

Is there a way or methods somewhere that maybe we can even edit, that tries to identify the signature?

(Apr-25-2019, 06:17 PM)Larz60+ Wrote: What have you tried so far?



RE: Remove Email Signature - Larz60+ - Apr-29-2019

Can't vouch for it, but found this package: https://github.com/mailgun/talon


RE: Remove Email Signature - PythonPaul2016 - Jan-01-2020

Mailgun's Talon library is okay. It's not super accurate.

SigParser's email parsing library is better in that it can handle multiple languages.