Manipulating mailboxes

Discussion in 'Python' started by Laszlo Zsolt Nagy, May 23, 2005.

  1. Hi All,

    I need to create a daemon that sits on a server and forwards some
    e-mails. (Well not only that, it needs to change header information
    before forwarding and also insert messages into a database). The mailbox
    module is fine but I do not see a way to delete/add messages - it is
    ready only. The other possiblity is IMAP4 but it is bad because my
    program should not store passwords for all users. I can only see one
    solution right now:

    1. Make a copy of the mailbox
    2. Truncate the mailbox
    3. Process the messages in the copy and forward the e-mails by sending
    out real e-mails.

    But this looks so clumsy. Is there a way to delete/add messages to
    mailboxes of different users, directly?

    Thanks,

    Laci 2.0
    Laszlo Zsolt Nagy, May 23, 2005
    #1
    1. Advertising

  2. Laszlo Zsolt Nagy

    Paul Rubin Guest

    Laszlo Zsolt Nagy <> writes:
    > But this looks so clumsy. Is there a way to delete/add messages to
    > mailboxes of different users, directly?


    Why not use procmail or equivalent to drop incoming messages into
    your daemon one at a time. Then use the smtp module to forward them
    to their actual destinations.
    Paul Rubin, May 23, 2005
    #2
    1. Advertising

  3. change header information, insert messages into a database, delete/add messages, should not store passwords for all users, ... and any things else you wish to do - if your OS is UNIX - just forward mail messages of some users to your python script (you don't need to write a daemon for this)
    All you need is to place file ".forward" in users home directory, and write like this:
    |/path/myscript.py

    and chmod the script:
    chmod 777 /path/myscript.py

    Laszlo Zsolt Nagy wrote:
    >
    > Hi All,
    >
    > I need to create a daemon that sits on a server and forwards some
    > e-mails. (Well not only that, it needs to change header information
    > before forwarding and also insert messages into a database). The mailbox
    > module is fine but I do not see a way to delete/add messages - it is
    > ready only. The other possiblity is IMAP4 but it is bad because my
    > program should not store passwords for all users. I can only see one
    > solution right now:
    >
    > 1. Make a copy of the mailbox
    > 2. Truncate the mailbox
    > 3. Process the messages in the copy and forward the e-mails by sending
    > out real e-mails.
    >
    > But this looks so clumsy. Is there a way to delete/add messages to
    > mailboxes of different users, directly?
    >
    > Thanks,
    >
    > Laci 2.0
    >



    --
    Best regards,
    Maksim Kasimov
    mailto:
    Maksim Kasimov, May 23, 2005
    #3
  4. Maksim Kasimov wrote:

    >change header information, insert messages into a database, delete/add messages, should not store passwords for all users, ... and any things else you wish to do - if your OS is UNIX - just forward mail messages of some users to your python script (you don't need to write a daemon for this)
    >All you need is to place file ".forward" in users home directory, and write like this:
    >|/path/myscript.py
    >
    >


    >and chmod the script:
    >chmod 777 /path/myscript.py
    >
    >

    Oh, fantastic. :) Then I can open stdin and read the e-mail message
    from there.
    Thank you so much

    Laci 2.0
    Laszlo Zsolt Nagy, May 23, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Parsing mailboxes

    , Aug 24, 2004, in forum: Perl
    Replies:
    1
    Views:
    439
    Steve Bennett
    Aug 27, 2004
  2. Sunil
    Replies:
    3
    Views:
    379
  3. Replies:
    1
    Views:
    406
    christian_harper
    Jul 26, 2006
  4. Grzegorz Adam Hankiewicz
    Replies:
    3
    Views:
    320
    Andrew Dalke
    Jul 13, 2003
  5. Grzegorz Adam Hankiewicz
    Replies:
    0
    Views:
    312
    Grzegorz Adam Hankiewicz
    Jul 26, 2003
Loading...

Share This Page