WordPress Security ServicesMalware Removal
Spam Email

Hacked WordPress Site Sending Spam Emails: How to Find the Source and Stop It

Your host emails you about outgoing spam. Your mailbox fills with bounce messages for emails you never sent. Your contact form emails stop arriving because your domain is blacklisted. A WordPress site sending spam is a common side effect of a hack, and it can get your hosting suspended fast. Here's how to find what's sending it, stop it, and repair your email reputation.

Sergey By Sergey, WordPress security specialist Updated 2 min read
In this guide
  1. Signs your WordPress site is sending spam
  2. Step 1: Find what’s sending the emails
  3. Step 2: Stop it
  4. Step 3: Clean the rest of the site
  5. Step 4: Repair your email reputation

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-Script or X-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 containing mail(, 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.

Sergey, WordPress Security Specialist
About the author
Sergey, WordPress Security Specialist

10 years in WordPress security and incident investigation, and more than 200 websites cleaned of malware. Top Rated on Upwork with a 100% Job Success score. More about me

Frequently Asked Questions

Is it my site or someone spoofing my domain?

Bounce messages alone don't prove your site sent anything. Spammers can fake the sender address. If your host reports spam from your account, or your mail logs show the messages, it's coming from your server. If not, set up SPF, DKIM and DMARC to stop spoofing.

Can a contact form send spam without a hack?

Yes. Bots can abuse forms that send a copy to the visitor, or that let them set the recipient. That's not malware, but it still damages your reputation. Add anti-spam protection and disable "send a copy to me" options.

How do I get my domain or IP off a blacklist?

First stop the spam completely, or the delisting won't last. Then check the main blacklists (Spamhaus and others) and follow each list's removal process. Many lists remove you automatically after a period without spam.

Need a hand?

Let me clean your WordPress site for you

Send me your site URL and what you're seeing. I'll reply with what I think is going on and the next step.

$95 per infected site · 1-month guarantee · direct contact with the specialist

Get My Site Cleaned →