Email Checking and Deletion Automation
Budget: $30 – $250 USD
This will need to cycle through the email accounts check for new or deleted
While cPanel does not offer a native feature to automatically delete emails older than 30 days, you can achieve this by implementing a custom PHP script in combination with a cron job.
Please find below an example of the steps to follow:
Write a Custom PHP Script:
You will need to create a PHP script (with the assistance of your developer) that connects to the mail server, checks the timestamps of emails in the inbox, and deletes those older than 30 days.
Save the script (e.g., delete_old_emails.php) in a directory accessible via cPanel or FTP.
Upload the Script:
Upload the PHP script to your cPanel file manager or via FTP.
Set Up a Cron Job:
Log in to cPanel and go to Cron Jobs under the Advanced section.
Add a new cron job to execute the PHP script at your preferred frequency. For example, to run the script daily, you can use the following cron command:
0 0 * * * php /home/yourusername/public_html/delete_old_emails.php
Be sure to replace /home/yourusername/public_html/delete_old_emails.php with the actual path to your PHP script.
Test the Script:
Before fully automating the process, we recommend testing the script to ensure it functions as expected, deleting only emails older than 30 days and not affecting other messages.
While cPanel does not offer a native feature to automatically delete emails older than 30 days, you can achieve this by implementing a custom PHP script in combination with a cron job.
Please find below an example of the steps to follow:
Write a Custom PHP Script:
You will need to create a PHP script (with the assistance of your developer) that connects to the mail server, checks the timestamps of emails in the inbox, and deletes those older than 30 days.
Save the script (e.g., delete_old_emails.php) in a directory accessible via cPanel or FTP.
Upload the Script:
Upload the PHP script to your cPanel file manager or via FTP.
Set Up a Cron Job:
Log in to cPanel and go to Cron Jobs under the Advanced section.
Add a new cron job to execute the PHP script at your preferred frequency. For example, to run the script daily, you can use the following cron command:
0 0 * * * php /home/yourusername/public_html/delete_old_emails.php
Be sure to replace /home/yourusername/public_html/delete_old_emails.php with the actual path to your PHP script.
Test the Script:
Before fully automating the process, we recommend testing the script to ensure it functions as expected, deleting only emails older than 30 days and not affecting other messages.