How to completely remove Post SMTP logged emails and session transcripts
Post SMTP is an awesome WordPress plugin, but I recently ran into a big issue with one website where the database was too slow to respond, and the 250 logged emails weighed 450+ Mb in the database.
This issue (or a shared server) caused hundreds of errors in my error.log
file:
WordPress database error Commands out of sync; you canโt run this command now for query [...]
Turning off email logging or changing the amount of logged emails did not remove the previously logged ones. There is no CRON job to run and delete these emails, so the only solution was to delete them straight from the database.
These are the queries I used to delete all logged emails. Nothing else is lost, API keys, email settings, sender settings, everything is preserved.
DELETE FROM `wp_postmeta` WHERE meta_key = 'session_transcript';
DELETE FROM `wp_postmeta` WHERE meta_key = 'original_headers';
DELETE FROM `wp_postmeta` WHERE meta_key = 'original_message';
DELETE FROM `wp_postmeta` WHERE meta_key = 'original_subject';
DELETE FROM `wp_postmeta` WHERE meta_key = 'original_to';
DELETE FROM `wp_postmeta` WHERE meta_key = 'transport_uri';
DELETE FROM `wp_postmeta` WHERE meta_key = 'reply_to_header';
DELETE FROM `wp_postmeta` WHERE meta_key = 'to_header';
DELETE FROM `wp_postmeta` WHERE meta_key = 'from_header';
DELETE FROM `wp_postmeta` WHERE meta_key = 'success';
DELETE FROM `wp_postmeta` WHERE meta_key = 'solution';