Jump to content

Add an IP address to your contact form


Bad Wolf

Recommended Posts

A very helpful friend sent me this tiny tutorial on adding an IP address in the contact form so you know where your contact came from. All too often my inbox is flooded with SPAM and it can be in the hundreds per day at times. I have found that by sleuthing out the IP address and blocking by country or IP range in the .htaccess file is a HUGE benefit to me. I understand that on a shop you really want to sell as much product to as many places you wish, but not everyone sells worldwide. I have a limit on countries and this works for me.

Quote

There will be one edit to the core code.

In /classes/cubecart.class.php, near line 1521, find:

$mailer->Body  = sprintf($GLOBALS['language']->contact['email_content'], $_POST['contact']['name'], $_POST['contact']['email'], $department, $enquiry);

Change to:

$mailer->Body = sprintf($GLOBALS['language']->contact['email_content'], $_POST['contact']['name'], $_POST['contact']['email'], $department, $enquiry, get_ip_address());

Then, in CubeCart's admin, Languages, click the Edit icon of the language you wish to change. On the next page, select Contact.

There will be list shown. Click on the words 'email_content'. The text box then become editable. Scroll to the bottom of the contents in the text box and add:


The Contact Us form was submitted from: %s


Save and have CubeCart clear its internal cache.

 

Link to comment
Share on other sites

Hello, I just tested and strange thing the email I receive is empty. I just have ‘this email is sent by: client name’

 

The Contact Us form was submitted from: %s

It's good it works but I changed this line by:

 

%s <%s> wrote to%s: ---------------%s --------------- This email is sent by the main e-mail addresses of the shops but it is possible to reply directly to the sender using the reply button on your e-mail software. ip address:%s

Link to comment
Share on other sites

Works fine for me. I used a proxy and it gave me the proxy IP instead. When I first tested it, it gave me the IP of my proper home IP.
I actually shortened the language (email addressed obviously changed for this purpose):

Quote
On Apr 29, 2020, at 7:23 AM, Bad Wolf Designs <BadWolf@myemail> wrote:

 

Twitchy <email@email> wrote to Bad Wolf Designs:
---------------
fasdfgchvjkl;
---------------

This email is sent from the store's master email address but it is possible to reply directly to the sender using the reply button on your email software.

Submitted from: 198.98.183.149

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...