Remove the signature from a MIME encoded email wit

2019-07-12 18:50发布

问题:

I am reading mails from a pop3 server with imap and decoding them with a mailparse class which uses PEAR Mimedecode.

I was wondering if there's any way to get the signature or just to remove it from the body of the mail.

Thanks.

回答1:

The signature is part of the body, so no, there isn't really a way to just remove the signature, unless you knew that every signature was going to have the exact same format.

If you knew that every signature was going to come after 10 hyphens, like this

Lorem ipsum lorem ispum.Lorem ipsum lorem ispum.Lorem ipsum lorem ispum.
Lorem ipsum lorem ispum.Lorem ipsum lorem ispum.
----------
Your Name

If that is the case, then you could just do

$message = explode('----------', $body);

Where $message[0] would be the body, and $message[1] would be the signature.