Skip to main content

Deleting Mails with Cron ???

Comments

14 comments

  • 24x7ss
    Ofcourse you can do this using cron. You can put below two commands in one file and set cron for that file. Suppose create /root/maildelete.txt. Put below commands in that file : rm -rf /home/{username}/mail/{domain.com}/{mailusername}/cur/* rm -rf /home/{username}/mail/{domain.com}/{mailusername}/sent/* and then set cron for /root/maildelete.txt
    0
  • mesut85u2
    Ofcourse you can do this using cron. You can put below two commands in one file and set cron for that file. Suppose create /root/maildelete.txt. Put below commands in that file : rm -rf /home/{username}/mail/{domain.com}/{mailusername}/cur/* rm -rf /home/{username}/mail/{domain.com}/{mailusername}/sent/* and then set cron for /root/maildelete.txt

    thanks for your help the command works for inbox, but not work for sent folder. there is not a "sent" folder. and i don't know where sent mails are storing... I add the my mail screenshot... If you know, how can i empty sent folder? One more, what is the meaning of "-rf" command?
    0
  • 24x7ss
    Hello, I forgot to mention the .(dot) for Sent folder. Use below syntax: rm -rf /home/{username}/mail/{domain.com}/{mailusername}/.sent/* Further, r means recursive and f means forcefully.
    0
  • mesut85u2
    thanks a lot for your help. and one more thing i found rm -rf /home/{username}/mail/{domain.com}/{mailusername}/.Sent/cur/* the bold part is important.
    0
  • 24x7ss
    Ok, Thanks for the update. We are glad that your issue gets fixed :)
    0
  • cPanelMichael
    Hello, I am happy to see the solution provided was helpful. Thank you for updating us with the outcome.
    0
  • mesut85u2
    Hi, I need one more help... All personels are using mail system, and all mails are forwarding personals' other mail address: for example, all mails are forwarding from main.address@domain.com to personel@gmail.com and it is working best. Problem: If you don't open webmail interface, cron job doesn't delete inbox mails. If you access webmail interface (you don't need to read mails), cron job delete inbox mails. WHY??? How can i delete inbox mails without access webmail interface because of forwarding all mails???
    0
  • danrussell
    Hi :), The cronjob should delete the emails in "cur" directory without accessing the webmail. Please check if you have set the cron correctly.
    0
  • mesut85u2
    Hi :), The cronjob should delete the emails in "cur" directory without accessing the webmail. Please check if you have set the cron correctly.

    hi danrussell, my cron job code is: rm -rf /home/username/mail/domain.net/mail_user_name/cur/* is there any mistake?
    0
  • mesut85u2
    I think i found the right code: find /home/{username}/mail/{domain.com}/{mail-user-name}/ -type d \( -name cur -o -name new \) -exec find {} -type f -delete \; example: username : sitenm domain: sitenm.com mail-user-name : info (info@sitenm.com) find /home/sitenm/mail/sitenm.com/info/ -type d \( -name cur -o -name new \) -exec find {} -type f -delete \;
    0
  • mesut85u2
    I think i found the right code: find /home/{username}/mail/{domain.com}/{mail-user-name}/ -type d \( -name cur -o -name new \) -exec find {} -type f -delete \; example: username : sitenm domain: sitenm.com mail-user-name : info (info@sitenm.com[/EMAIL]) find /home/sitenm/mail/sitenm.com/info/ -type d \( -name cur -o -name new \) -exec find {} -type f -delete \;

    I am testing this code, i hope it works well... I will write the stuation...
    0
  • cPanelMichael
    Feel free to update us with the outcome after testing out your cron job. Thank you.
    0
  • mesut85u2
    It is working best, no problem... I am using that. thanks your helps.
    0
  • cPanelMichael
    I am happy to see the issue is now resolved. Thank you for updating us with the outcome.
    0

Please sign in to leave a comment.