In this guide
Signs your WordPress site is sending spam
- Your host warns about outgoing spam, limits your email, or suspends the account.
- Bounce messages for emails you never sent.
- Your own emails stop arriving, or land in spam folders.
- Your domain or server IP appears on email blacklists.
- Unusual server load with no matching increase in visitors.
Step 1: Find what’s sending the emails
- Ask your host for the mail logs, or check them in your control panel. On many servers, outgoing PHP mail carries a header naming the script that sent it (for example
X-PHP-ScriptorX-PHP-Originating-Script). That points straight at the file. - Look at a few of the spam messages if you can get them, especially the headers.
- Search for mailer scripts: PHP files in
uploads, or random-named PHP files containingmail(, mass-sending loops, or long encoded strings. - Check your contact forms, in case the “spam” is form abuse rather than malware.
- Check whether your SMTP password was stolen. If the spam goes out through your email account rather than PHP, the account itself is compromised.
Step 2: Stop it
- Delete the mailer scripts and any backdoor that uploaded them, because one usually comes with the other.
- Change your email account and SMTP passwords, and any SMTP or API keys stored in plugins.
- Ask your host to clear the outgoing mail queue, so thousands of queued spam emails don’t go out after you’ve fixed it.
Step 3: Clean the rest of the site
Spam mailers are usually just one part of an infection. Follow my step-by-step guide to fixing a hacked WordPress site, and use Is this file malware? to check suspicious file names.
Step 4: Repair your email reputation
- Check your domain and server IP on the main blacklists and request removal where needed.
- Set up SPF, DKIM and DMARC for your domain, so your real emails are trusted and spoofed ones are rejected.
- Consider sending WordPress emails through a dedicated email service via SMTP, instead of the server’s own mail function.
From my cleanup work: in most spam-sending cases, the mail header points to a single file buried in an uploads folder from years ago, like wp-content/uploads/2019/04/x.php. Deleting it stops the spam. But it got there through something, and that backdoor and the outdated plugin behind it are what the rest of the cleanup is for.
If your host has suspended the account for spam, my hacked website cleanup includes stopping the spam and helping you get the account reactivated.