Software, your way.
burger menu icon
WillMaster

WillMaster > LibraryWebsite Email

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Rating by Email Software

To implement a rating feature for your outgoing email, two things are needed.

  • The rating software.
  • Links in the email.

When implemented, your email will have character links something like this:

Before putting the rating links into your email, the rating software needs to be installed on your server. It is a PHP script.

Here is the source code. Notes follow.

<?php /*
Email Rate Log
Version 1.1
October 20, 2023
Will Bontrager Software LLC
https://www.willmaster.com/
*/

/* Two places to customize (article has instructions). */

// (1) The location of the CSV log file.
$LogFile = __DIR__.'/EmailVoteLog.csv';

// (2) The content to show after rating.
$ContentToDisplay = <<<CONTENT
<div style="display:table; margin:.25in auto;">
<p>Thank you!</p>
<p>Your feedback is appreciated.</p>
</div>
CONTENT;

/* Customization complete. */
$LogLine = array();
$LogLine[] = str_replace('"','""',date('r'));
$LogLine[] = $_SERVER['REMOTE_ADDR'];
$LogLine[] = rawurldecode($_SERVER['QUERY_STRING']);
file_put_contents($LogFile,'"'.implode('","',$LogLine)."\"\n",FILE_APPEND);
echo $ContentToDisplay;
exit;
?>

Notes:

Copy the source code and save the file as emailvote.php (or other *.php file name that you prefer). The following customizations may be changed before installing the software.

  1. The __DIR__.'/EmailVoteLog.csv' value tells emailvote.php that the CSV file is in the same directory as emailvote.php and that EmailVoteLog.csv is the name of the CSV file.

    If you want the CSV to have a different file name or be stored in a different location, change __DIR__.'/EmailVoteLog.csv' accordingly.

  2. The red text is the content and HTML markup to publish when someone taps your rating link. You'll see it in the source code between the lines that have the word CONTENT within them.

    If you make no changes, the script will output something like this:

    Thank you!

    Your feedback is appreciated.

    If you want to publish a different message, change the red text accordingly.

When the customizations are done, upload emailvote.php to your server. Make a note of the script's URL. You will use the URL in the links to be published in your email.

With emailvote.php installed and its URL at hand, let's put the voting links into an email.

Here is the source code.

<div style="display:inline-block; margin-right:2em;">
<a href="https://example.com/emailvote.php?vote=yes&issue=1265"><span style="font-size:50px; color:#090;">&#10004;</span></a> 
</div>
<div style="display:inline-block;">
<a href="https://example.com/emailvote.php?vote=no&issue=1265"><span style="font-size:50px; color:#f00;">&#10006;</span></a> 
</div>

Paste the above into your email and then replace both instances of https://example.com/emailvote.php with the URL of your newly uploaded emailvote.php script.

Also change or remove the &issue=1265, if you wish. You may also add other URL parameters, anything you want to keep track of.

The CSS may be changed as needed.

When a voting link is clicked, the CSV file logs the time, the IP address, and whatever parameters the voting link had at the time it was clicked.

Because the IP address is logged, it is relatively easy to remove duplicate votes.

Put the voting links in every email that you want votes for.

(This content first appeared in Possibilities newsletter.)

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC