Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

cron job to delete mail through pop3

  • 10-05-2002 7:37pm
    #1
    Registered Users, Registered Users 2 Posts: 15,544 ✭✭✭✭


    Want to write a script on a site of mine that will run a cron job that will automatically connect to a mailbox through pop3 and delete its contents periodically.

    Not sure exactly how to get started on this, can someone suggest how or where i can find info on doing such a thing?

    Have a weather station?, why not join the Ireland Weather Network - http://irelandweather.eu/



Comments

  • Registered Users, Registered Users 2 Posts: 476 ✭✭Pablo


    http://webmasterworkshop.com/guides/crontab_guide.shtml

    about basic cron stuff

    if you don't want the emails why not just disable the account or ignore it.


  • Registered Users, Registered Users 2 Posts: 15,544 ✭✭✭✭Supercell


    if you don't want the emails why not just disable the account or ignore it.

    Sorry should have explained it, suppose it does seem a bit weird, i get notified by satellite of the subject..which is all i need..its a chat project i'm working on..after the subject is sent..i dont need the mails..as the content is irrelevant.

    The mailbox can hold a few thousand mails=a few thousand lines of chat..before it needs to be emptied , i need this to be automated if possible, a cron job seems to be the logical way to go about it.

    Have a weather station?, why not join the Ireland Weather Network - http://irelandweather.eu/



  • Registered Users, Registered Users 2 Posts: 1,842 ✭✭✭phaxx


    If you have shell access to the server, you can use procmail to filter the mail as it comes in and delete it, save the subject line, etc.


  • Registered Users, Registered Users 2 Posts: 7,521 ✭✭✭jmcc


    Originally posted by Longfield
    Want to write a script on a site of mine that will run a cron job that will automatically connect to a mailbox through pop3 and delete its contents periodically.

    Not sure exactly how to get started on this, can someone suggest how or where i can find info on doing such a thing?

    Not sure if this is a straight script problem or one that requires a better scripting language such as TCL or Python.

    Basically the flow would be:
    The actual commands are in [] brackets.

    Connect to pop3 server [telnet boxname 110]
    Login to pop3 server [user username]
    give password [pass password]
    list messages
      (or [stat] ) Parse message numbers from list then loop through deleting message numbers [dele 1] finish loop [quit] Alternatively the STAT command can also give you the number or messages in the mailbox and you can parse this (typically the response should be '+OK n mboxsize') to give you the number of messages to delete. You could probably parse the results with grep and keep the whole thing as a shell script as long as you have set the error conditions. Running the thing on crontab would be fairly easy. (man crontab). Check the basic pop3 commands and also look for details of Expect (man expect) which allows for this kind of thing. Test the script locally first. Regards...jmcc


Advertisement