Page 1 of 7

[mod] View HTML Email in Browser

PostPosted: 9:51pm, Mon 12 Jan, 2009
by xannonite
##############################################################
## MOD Title: View HTML E-mail in Browser
## MOD Author: xannonite
## MOD Description: This mod allows you to create a 'view in browser'
## link for HTML emails using a [VIEWMESSAGEURL] tag.
## MOD Version: 1.2.3
##
## Installation Level: Moderate
## Installation Time: 10 Minutes
## Files To Edit: connect.php, sendemaillib.php, structure.php
## Included Files: vm.php, messageview.sql
##############################################################
## Author Notes: Use the .sql file to create the necessary
## database table for an existing installation
##############################################################
## Before Installing This MOD, You Should Back Up All Related Files
##############################################################
## History:
## 1.0 - 20090112 - Initial release.
## 1.2 - 20090112 - Modified to save emails using both messageid
## and uniqid so that personalization is maintained.
## 1.2.1 - 20090113 - Added timestamp column to database table,
## added separate .sql file for UTF-8 for convenience.
## 1.2.2 - 20100711
## - Checks for and updates existing message
## before attempting to insert a new one.
## - Modified vm.php to retrieve the most recent version
## of a message.
## - Added instructions for modifying .htaccess.
## 1.2.3 - 20111026
## - Added a check to make sure forwarded messages aren't
## saved to the database.
##############################################################

This mod will cause phplist to save a copy of all sent HTML e-mail messages to a table in the database. You can then add a link to view a message in the user's browser like so:

Code: Select all
<a href="[VIEWMESSAGEURL]">Click here to view the message in your browser</a>


The link will pass the message ID and the user's unique ID to vm.php, which will in turn display the message stored in the database.

##############################################################

Download v1.2.3
Download v1.2.2
Download v1.2.1
Download v1.2
Download v1.0

##############################################################

PostPosted: 9:54pm, Mon 12 Jan, 2009
by CS
Sounds like a nice mod. I'm guessing you tried to attach the files for the mod, which sadly, the forums will not let you do. They will have to be hosted remotely.

PostPosted: 9:55pm, Mon 12 Jan, 2009
by xannonite
CS wrote:Sounds like a nice mod. I'm guessing you tried to attach the files for the mod, which sadly, the forums will not let you do. They will have to be hosted remotely.


Well, since I have less than 10 posts, it won't let me add a link. For now people will just have to contact me for the mod.

PostPosted: 10:00pm, Mon 12 Jan, 2009
by CS
Send me the link in PM, I'll post it for you.

PostPosted: 10:13pm, Mon 12 Jan, 2009
by xannonite
CS wrote:Send me the link in PM, I'll post it for you.


ok, I sent the link. Thanks.

PostPosted: 10:29pm, Mon 12 Jan, 2009
by CS

PostPosted: 11:06pm, Mon 12 Jan, 2009
by CS
I've glanced over your code and it looks like a nice mod, but unless I overlooked something, it appears that it is inserting the message into the messageview table again for every user the message is sent to, and it is doing so after the standard placeholders have been processed, so that when viewed, it will show the unsubscribe, etc links for the last user the mail was sent to.

I wonder if the script could be simplified by bypassing the messageview table entirely and instead adding the user's hash to the messageview link and copy the attribute replacement code from sendemaillib.php to vm.php, thus duplicating the user's email.

PostPosted: 1:08am, Tue 13 Jan, 2009
by xannonite
Updated to version 1.2. The location is the same, but the file name is as follows:

phplist_vib_mod_1.2.zip

The code was changed for all of the files except connect.php, and the table structure was also changed, so I would recommend removing v1.0 and then applying v1.2.

PostPosted: 1:14am, Tue 13 Jan, 2009
by xannonite
CS wrote:I've glanced over your code and it looks like a nice mod, but unless I overlooked something, it appears that it is inserting the message into the messageview table again for every user the message is sent to, and it is doing so after the standard placeholders have been processed, so that when viewed, it will show the unsubscribe, etc links for the last user the mail was sent to.

I wonder if the script could be simplified by bypassing the messageview table entirely and instead adding the user's hash to the messageview link and copy the attribute replacement code from sendemaillib.php to vm.php, thus duplicating the user's email.


Yes, I had originally considered turning the sendEmail() function into a viewEmail() function, however the enormity of the code and my great distaste for duplicating procedures caused me to choose otherwise. I needed to create something quickly. However, now that I have a usable mod to tide me over, I can look into re-engineering the sendEmail() function for a future release (unless someone else beats me to it, hehe.)

PostPosted: 4:18pm, Tue 13 Jan, 2009
by CS
Here's the new link: http://xannon.com/files/phplist_vib_mod_1.2.zip

I agree about duplicating procedures. Of course, it would probably need to actually be incorporated into the base code to be worth the effort, but the ideal way to implement this mod would be to place most of the code from the sendEmail() function into a createEmail() function that could be called by both sendEmail() and a new viewEmail() function.

By the way, the update looks good functionally, but as it is creating a copy of the message content for each person the message is being sent to, it could use up considerable storage space for larger lists.

PostPosted: 5:33pm, Tue 13 Jan, 2009
by xannonite
CS wrote:By the way, the update looks good functionally, but as it is creating a copy of the message content for each person the message is being sent to, it could use up considerable storage space for larger lists.


Yeah, the storage needed for large lists is the main downside. The table will need to be cleaned out periodically.

To facilitate that, I added a 'modified' column to the messageview table to store a timestamp. The new file is:

phplist_vib_mod_1.2.1.zip

PostPosted: 5:47pm, Tue 13 Jan, 2009
by CS
Link: http://xannon.com/files/phplist_vib_mod_1.2.1.zip

Assuming that neither the messages or the lists are massive (rule of thumb: a 10k message sent to 1000 users will take 10MB of storage, a 10k message sent to 10,000 users will take 100MB of storage), that should work. People can setup a cron job to remove anything older than x days/weeks.

PostPosted: 8:51pm, Tue 13 Jan, 2009
by Guest
Perfect! Just looking for it.

PostPosted: 1:35pm, Wed 14 Jan, 2009
by Guest
I kept having trouble with the field "uniqid" not inserting into the table, everything else seems fine.

messageid uniqid data modified
77 <html> 20:25:38

I have the latest one installed[/img]

PostPosted: 9:23pm, Wed 14 Jan, 2009
by xannonite
iammcse wrote:I kept having trouble with the field "uniqid" not inserting into the table, everything else seems fine.

messageid uniqid data modified
77 <html> 20:25:38

I have the latest one installed[/img]


The last link posted actually points to v1.2. Make sure you have version 1.2.1. The location is the same, but the filename is phplist_vib_mod_1.2.1.zip.

Otherwise, if you could dump your messageview table structure and post it or send it to me, I can see if everything is setup correctly.

Did you create the table using the .sql file, or did you use the 'initialise database' function on the admin page?

p.s. If you posted an error message, it didn't display properly. Try disabling HTML in the post or using the [ code ] BBCode tag.