Before Moving Forward Read Important Note Below:
.htaccess deny rules are meant to block web requests (HTTP, HTTPS) to the directory in which the .htaccess is placed. Spam messages are sent via SMTP, and this protocol is not affected by the .htaccess file on your website. The .htaccess file will only work to prevent these IP’s from visiting your website, but will not have any effect on their ability to send you e-mail via SMTP.
If they are using a form on your website to send the spam messages, this might still be a valid solution. Otherwise, it is extremely unlikely that this will resolve your problem. If you are unsure of how the spam messages are being sent, you can refer to the message headers of the spam you are receiving. Now note down IP address from where SPAM is being sent to your E Mail ID & then block those IP under SMTP block list inside your Mail Server settings.
Gone were the days when you have to read & reply only 2 to 3 emails a day. In today’s technology age if you are from IT (Information Technology) related company you may be receiving 50 emails a day & replying & writing same & 50 additional emails to peoples & colleagues.
But it gets worst when Spammer starts to send you 50 SPAM mails everyday & if you have email ID attached to your personal domain other than that’s of Yahoo! & Gmail then you are irritated & disgusted to hell as you are receiving 50 to 100 SPAM email without indication hoe to stop & unsubscribe from that.
In my case I was receiving 50 mails per day for 1 month & beyond i.e. for 45 days & I was already blocked 700 email IDs in email block list.
I even contacted my hosting service provider but no prevail they just run away from problem by saying blocking the address is only the solution & only advice & help they can provide.
So I investigated on my own & finally I found the solution,
& Here it was:
Note: I assume you are on Macintosh system using OSX or any other operating system with local email management client like ‘Apple Mail’.
Step 01: Select SPAM message that you have received
Step 02: Click on ‘Show (or hide) all headers’ button at menubar i.e. Open Show Header of your SPAM message where you will find all source information about from what IP email was sent using what machine & which operating system. We need only require information of IP address only. Copy that IP address in notepad app.
Step 03: Repeat above two steps for all other SPAM messages.
Step 04: Collect all IPs & rage of IPs those are similar or same. Now we have to block this IP Addresses in our server’s .htaccess file located at root.
Step 05: If you have IP Address something like this: 188.8.131.52
Then copy paste following code in your .htaccess file
order allow,deny deny from 184.108.40.206 allow from all
If you are receiving SPAM for Multiple IPs within range of above IP e.g. 220.127.116.11 & 18.104.22.168 & 22.214.171.124 & 126.96.36.199
Then copy paste following code in your .htaccess:
order allow,deny deny from 155.55.155. allow from all
You are done!
Note: Above IP Address i.e. 188.8.131.52 is for example purposes only. Use your own unique Spammer’s IP & replace it within above code.
Hope it helps,
Thanks & Regards