#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2008
    Posts
    78
    Rep Power
    7

    Remove text signatures from posted emails


    Hi,
    I love the idea of regular expressions... but I have no idea how they work.
    I don't *
    really* need to learn them as I almost never need them. (and devshed crowd is so helpful)

    I was hoping someone might help me (by that i mean, write it for me) strip and email signature off emails that get posted to a website.

    The email sig is n this format
    Name Surname
    I.T Consultant
    123 Computer Company
    e. user@domain.com
    m. 0432 567 456
    Or at least very close.

    It is sometimes a picture signature too that I would need to strip out.

    If I could get some help with this, that would be great.

    ===


    I would also be ok with something a simple as *find the @ from the email address, remove 2 lines below and four lines above* and simply tell users they cannot post email addresses at all in the posts.

    We are all from the same IT company so you could also do something by finding the 123 Computer Company name.

    Cheers.
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    Devshed tried that, people just end up posting "myname_at_mysite_dot_com"

    While it's possible to detect emails, URLs, and phone numbers in posts and throw errors when they occur, we'll need to know (at the very least) what language you're using to handle the posts and where the data is coming from.

    -Dan
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2008
    Posts
    78
    Rep Power
    7
    MD,
    While what you say is definately correct for public forums, this forum is private and is for use in a franchise business where everybodys email must conform to the standard.
    Stripping emails from within a post is not the goal, it is to strip the signature of the person who posted the message.
    I'll give you the full run down of what this is about.
    ----
    We have a mail out called TechTalk. When a franchisee sends a message to techtalk@[itcompany.com], every franchisee gets sent a copy. It's for asking questions about jobs for other franchisees to help with.
    We have decided to keep records of these emails in a forum so people can search the forum for previously asked questions and answers.
    So... when a franchisee sends a message to techtalk, it will also send a copy to the forum for posting.
    The forum uses mail2forum to create a thread and insert the email body as the post.
    Since it is email that is being used to create the messages and replies, they will have peoples email signatures in them.
    Because people come and go as franchisees, we do not want contact details listed for people who might have left the group, so we are stripping all signature details out of the posts.
    -----
    So... stripping urls and email addresses from the posts is not the goal, the signature is the only thing that needs to be stripped out.

    As I stated, I rekon we could even look for the company name in the signature, as every franchisee has this, and remove a certain number of lines before and after. Or look for a pattern that has the company name and email within 1-2 lines of each other and remove a certain number of lines before and after.

    Hope this explains more clearly.

    Thanks
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    This removes 3 lines before and 1 line after any email address:
    PHP Code:
    $message "Hello, I write single to salute and wait for answer again.

    Name Surname
    I.T Consultant
    123 Computer Company
    e. user@domain.com
    m. 0432 567 456

    Sometimes there may be a PS after the message, make sure you grab that without breaking anything."
    ;

    $message preg_replace("#^(.+?)(?:[^\n]+\n){3}(?:e\.\s+)?[a-z0-9_\+\-\.]+@[a-z0-9_\+\-\.]+(?:[^\n]+\n){2}(.*)$#is""\\1\n\\2"$message "\n");
    print(
    $message); 
    -Dan
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2008
    Posts
    78
    Rep Power
    7
    cheers.

IMN logo majestic logo threadwatch logo seochat tools logo