You are here:  » automatic generated email

Support Forum



automatic generated email

Submitted by rolli1 on Sat, 2012-03-17 10:16 in

Hi David,
is it possible that an automatical email is generated to my emailaddress when a customer clicks on the buy-url, containing this information?

regards
Roland

Submitted by support on Sun, 2012-03-18 10:48

Hi Roland,

I would be very careful implementing this incase you suddently get bombarded with email when your site is crawled - particularly by something that does not obey robots.txt! On which point; first of all double check that jump.php is excluded in your robots.txt, either on its own as per the example below or together with other recommended exclusions as in robots.txt.dist.

User-Agent: *
Disallow: /jump.php

With that in place, the next "line of defence" i would implement would be to set a cookie on the product page view that is then checked in the jump script which only sends the email if it is present.

To do this, look for the following code in products.php at line 101:

  require("html/header.php");

...and REPLACE with:

  setcookie("eml","1");
  require("html/header.php");

Finally, look for the following code in jump.php beginning at line 4:

  $sql = "SELECT filename,buy_url FROM `".$config_databaseTablePrefix."products` WHERE id=".database_safe($_GET["id"]);
  database_querySelect($sql,$rows);
  $product = $rows[0];

...and REPLACE with:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE id=".database_safe($_GET["id"]);
  database_querySelect($sql,$rows);
  $product = $rows[0];
  if (isset($_COOKIE["eml"]))
  {
    mail("you@example.com@","Click Report",print_r($product,TRUE));
  }

The email contents will the be full product record displayed using PHP's print_r() function so you will be able to see the full details.

I would strongly recommend testing this using a "throwaway" account first rather than your primary email address!!!

Cheers,
David.
--
PriceTapestry.com

Submitted by rolli1 on Thu, 2012-03-29 15:26

Hi David,
I did the proposed changes today and will report my experiences with it.

Thanks and best regards

Roland

Submitted by rolli1 on Thu, 2012-03-29 16:30

Hi David,
it males exactly that what I wanted to have. This gives me controle over my merchants back.

Regards

Roland

Submitted by moparr360 on Wed, 2012-12-19 01:24

Hello David

I am wanting to create a report for "buy url links" Will this email option be available to be sent as an Excel or CSV file?

I am planning on advertising for sites and want to be able to give them a report of the traffic I send to them and for what product.

Also maybe only send data once per week.

Is this possible.

Thank You
Bobby

Submitted by support on Wed, 2012-12-19 09:15

Hello Bobby,

The easiest thing to do would be to log clicks to a .csv file on the server, and then have a script email you that file once a week. Very easy to create the log, first make a folder "logs" in your Price Tapestry installation folder, and make sure that it is writable by PHP (easiest way to do that is normally with your FTP program - right click on the new folder in the remote window, then look for Permissions or maybe Properties... and then Permissions and give WRITE access to all users - Owner/Group/World).

Then to log clicks, edit jump.php look for the following code at line 4:

  $sql = "SELECT filename,buy_url FROM `".$config_databaseTablePrefix."products` WHERE id='".database_safe($_GET["id"])."'";

...and REPLACE with:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE id='".database_safe($_GET["id"])."'";

Then look for the following code at line 8:

  $product = $rows[0];

...and REPLACE with:

  $product = $rows[0];
  $logfilename = "logs/clicks.csv";
  $logfile = fopen($logfilename,"a");
  fwrite($logfile,$product["merchant"].",".$product["buy_url"]."\n");
  fclose($logfile);

You could of course fetch this off the server and delete manually, but if you wanted to email the file contents and then delete, you could create a CRON job to execute a script as follows:

scripts/maillog.php

<?php
  $logfilename 
"../logs/clicks.csv";
  
mail("you@example.com","Click Log",file_get_contents($logfilename));
  
unlink($logfilename);
?>

Sending as an attachment is trickier but there are some PHP/PEAR libraries which you can use, you'll need PEAR::Mail and PEAR::Mail_Mime (they may already be installed - many hosting companies have PEAR libraries pre-installed for customers to use). Then, modify the above script as follows:

<?php
  
include_once('Mail.php');
  include_once(
'Mail_Mime/mime.php');
  
$logfilename "../logs/clicks.csv";
  
$body = new Mail_mime();
  
$body->setTXTBody("See Attached...");
  
$body->addAttachment($logfilename);
  
$body $body->get();
  
$headers $message->headers(array("Subject"=>"Click Log"));
  
$mail Mail::factory("mail");
  
$mail->send("you@example.com"$headers$body);
  
unlink($logfilename);
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by moparr360 on Wed, 2012-12-19 15:34

Hello David

Thank you very much, you are awesome. Took about 2 minutes and works great. I will just fetch it from my server, easier for me to do this way.

Thank You
Bobby