The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

forward mail to file

Discussion in 'E-mail Discussions' started by TechGuy, Dec 16, 2005.

  1. TechGuy

    TechGuy Well-Known Member

    Joined:
    Nov 29, 2001
    Messages:
    60
    Likes Received:
    0
    Trophy Points:
    6
    How can I have all new messages to a particular email address automatically saved to a file like /mail/testing.txt

    Is there a way to pipe it to a script that can write the file, for example? Thanks!
     
  2. RickG

    RickG Well-Known Member

    Joined:
    Feb 28, 2005
    Messages:
    238
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    North Carolina
    Not certain what the long-term objective is, but rather than worrying about a script, what not take a simpler route and create a new mail account (called archive, for example). Then create a forwarder so any mail addressed to the primary account also forwards to the "archive" mailbox.
     
  3. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    In short, yes.

    Email filters in cPanel can be set to pipe email to a script (Perl, PHP or whatever you fancy).

    Using PHP, the process of reading mail in from STDIN is really really straightforward and the process of then appending the email contents to a file is dead simple if you want to store absolutely everything. On the other hand, if you want to store only the body of emails, and in a human-readable format, you've got more of a challenge on your hands, but it's by no means impossible.
     
Loading...

Share This Page