Newsletter Made Simple (NMS) for CMS Made Simple (CMSMS) is an easy to use bulk mailer, which I have been using for a few years now. In this blog post I will explain some of the functionality problems I have come across and the solutions I use to make NMS my bulk mailer of choice.
I have tired other bulk mailing programs, such as the very popular phpList, but it's nice to just have a native bulk mailer inside the content management system (CMS). A big thank you to lemkepf, calguy1000, and nuno for developing the NMS code. It just needed a few tweaks.
Each solution below has been checked and they all work with version 2.3.2 of NMS. All of the tweaks (problems and solutions) below were created when I was running version 2.2.3 of Newsletter Made Simple (NMS).
Sometimes you want to have a private list of a select group of customers or site visitors. By default Newsletter Made Simple will not allow people on a private list to remove themselves.
If a user wants off a list they have the right to remove their email address from our bulk email lists regardless if it is public or private. In the United Sates we also have the CANSPAM laws for those business owners who just don't get that bulk emailing is infact not cheap bulk postal mail.
Open the file: action.unsubscribe.php
Near line 75 find:
$query = "SELECT A.listid FROM ".NMS_LIST_TABLE." A,
".
NMS_LISTUSER_TABLE." B WHERE A.listid = B.listid AND A.public =
1
AND B.userid = ?";Change it to:
// modified to delete membership from all lists both public and private
$query = "SELECT A.listid FROM ".NMS_LIST_TABLE." A,
".
NMS_LISTUSER_TABLE." B WHERE A.listid = B.listid
AND B.userid = ?";This problem has been fixed in NMS version 2.3.2.
When a user tries to change the lists they are subscribed to, and they don't check the boxes next to any lists, Newsletter Made Simple will throw the following error:
Warning: Invalid argument supplied for foreach() in/home/cantitoe/public_html/modules/NMS/action.do_usersettings.phpon line 78
The user doesn't need to see that error.
Open the file: action.do_usersettings.php
Near line 76 find:
// convert the lists array into a flat array
$newlists = array();
foreach( $params['lists'] as $newelem )
{
$newlists[] = $newelem[0];
}Change it to:
// convert the lists array into a flat array
$newlists = array();
// added a check here to see if anything was selected
if (isset($params['lists'])) {
foreach( $params['lists'] as $newelem ) {
$newlists[] = $newelem[0];
}
}Some of my clients want to use Outlook or some other 3rd party application to manage customers. To update their bulk email lists, they import and export csv files.
If a user has unsubscribe from a list, their email address can inadvertently be put back on the list during a CSV file import. Not good for those of us in the United States; CANSPAM laws again.
What I prefer to do is check for email address that already exist in the newsletter database. If an email address exists in the database I have come up with two acceptable ways of handing the situation:
Open the file: action.do_import_users.php
Near line 132 find:
$userid = $db->GetOne($query,array($email));Add after it:
// user exists in database flag
$userInDBFlag = ( !$userid ) ? False : True;Near line 158 find:
// and add him to the list(s)
$query = 'INSERT INTO '.NMS_LISTUSER_TABLE."
(userid,listid,active,
entered)
VALUES (?,?,1,$now)";
foreach( $params['input_lists'] as $listid )
{
$dbr = $db->Execute($query, array($userid,$listid));
if( $dbr )
{
$membershipsadded++;
}
}Change it to (Method One):
// and add him to the list(s)
// METHOD ONE: just ignore all old users already in the DB
if( !$userInDBFlag ) {
$query = 'INSERT INTO '.NMS_LISTUSER_TABLE."
(userid,listid,active,
entered)
VALUES (?,?,1,$now)";
foreach( $params['input_lists'] as $listid )
{
$dbr = $db->Execute($query, array($userid,$listid));
if( $dbr )
{
membershipsadded++;
}
}
}The default action for the NMS unsubscribe {$unsubscribe} is a multi-step process. When the user clicks the unsubscribe link in the bulk email it takes them to the website, which then sends them another email with the actual unsubscribe link. This means the user has to open the second email and click the actual un- subscribe link.
The problem with this is that in some cases the user never looks at the second email, thinking it is just a notice about a successful unsubscribe. They then complain that the unsubscribe link doesn't work.
I prefer to make the unsubscribe process a one step process. The following changes make the unsubscribe link {$unsubscribe} go directly to the unsubscribe process.
Open the file: action.defaulturl.php
Near line 60 find:
case 'unsub_email':
$action = 'unsubscribe_email';Change it to:
case 'unsub_email':
$action = 'unsubscribe';This problem has been fixed in NMS version 2.3.2.
The NMS code generates absolute links when it process jobs. This is great for everything in an email, except for, on page anchors. An in this newsletter table of contents is an example use of this. This default behavior changes href="#someAnchor" to something like href="www.yoursite.com/#someAnchor".
The following fix keeps on page anchors as relative so they work when the email is opened by the receiver href="#someAnchor".
Open the file: function.utils.php
Near line 144 find:
//Inputs the extracted string into the function make_abs
$output_uri = _make_abs($input_uri, $base_url);
echo "DEBUG: src1 = $src, input_uri = $input_uri, output_uri =
$output_uri, ";
$input_uri = str_replace('?','\?',$input_uri);
//Replaces the relative URI with the absolute one
$src =
eregi_replace("((href|src|action)=\")$input_uri(\")",
"\\1$output_uri\\3", $src);
echo "DEBUG: src2 = $src<br /><br />";Change it to:
//do not turn # anchor links into fully qualified URLs
if(!preg_match('/#(.*)/i',$input_uri)) {
//Inputs the extracted string into the function make_abs
$output_uri = _make_abs($input_uri, $base_url);
echo "DEBUG: src1 = $src, input_uri = $input_uri, output_uri =
$output_uri, ";
$input_uri = str_replace('?','\?',$input_uri);
//Replaces the relative URI with the absolute one
$src =
eregi_replace("((href|src|action)=\")$input_uri(\")",
"\\1$output_uri\\3", $src);
echo "DEBUG: src2 = $src<br /><br />";
}