Scope:You installed the infusion
newsletter_panel version 1.2 or 1.6.
When you try to send out the newsletter you get this error:
[center]The Newsletter could not be sent.
Please ensure sendmail is configured correctly.[/center]
The problem in a nut shell:The problem is that the table that holds the subscriptions contain "dead links", i.e. references to users that don't exist anymore.
This happens when a user that has subscribed to the newsletter is deleted WITHOUT unsubscribing to the newsletter first.
This is very much likely to happen, because the administrator must remember to delete the subscription in the infusion BEFORE deleting the user, and this could easily be forgotten.
The subscription table is called
fusion_newsletter_subs, and it has only two fields:
newsletter_sub_id: Sequence number (autoincrement)
newsletter_sub_user: Reference to table
fusion_users; field
user_idExample:Fusion_newsletter_subs:
Sub_id sub_user1 ------- 31
2 ------- 43
3 ------- 25 <----
4 ------- 18
Let's assume that for sub_id = 3 there is a problem because someone deleted the user with
user_id 25 from table
fusion_users, WITHOUT removing the subscription.!
So, his subscribtion still exists as post3 in
Fusion_newsletter_subs, causing the sendout of the newsletter to fail.
There are several options for how to solve the problem:
1.Change members.php, so that when a user is deleted the reference in
fusion_newsletter_subs is deleted too. However, this will cause that it's no longer an infusion, but a MOD.
2.Change
newsletter_admin.php to cope with "dead refs" so it doesn't fail when the newsletter is sent out.
Pure symptom treatment. I don't like it at all!
3.Make a "clean-up" php to be called from
newsletter_subs.php.
4.Change
newsletter_subs.php, so that you may see and delete the dead refs.
I choose solution 3 because
newsletter_subs.php actualy shows the dead ref from
fusion_newsletter_subs and you may also click "Delete" to get rid of it.
The delete function however contains an error.
When this is solved, dead refs appear as blank subscriptions at the top of the list and can easily be removed.
Problem is that the LEFT JOIN that fills the workspace does not take the reference from table
fusion_newsletter_subs but instead uses the empty value from
fusion_users-user_id.
Empty because a LEFT JOIN leaves empty fields in case no related record is found in the joined table.
So, I corrected the SELECT to add an extra field to the workspace;
fusion_newsletter_subs-newsletter_sub_user, and use this as reference when a subscription must be deleted.
The correction in newsletter_subs.php:Insert with red:
$result = dbquery(
"SELECT [color=red]newsletter_sub_user, [/color]tns.*, tu.user_id,user_name,user_email FROM ".$db_prefix."newsletter_subs tns
LEFT JOIN ".$db_prefix."users tu ON tns.newsletter_sub_user=tu.user_id".$orderby
);
$rows = dbrows($result);
if (!isset($rowstart)) $rowstart = 0;
$result = dbquery(
"SELECT [color=red]newsletter_sub_user, [/color]tns.*, tu.user_id,user_name,user_email FROM ".$db_prefix."newsletter_subs tns
LEFT JOIN ".$db_prefix."users tu ON tns.newsletter_sub_user=tu.user_id
".$orderby."ORDER BY user_name LIMIT $rowstart,20"
);
Replace orange by red:
</tr>\n";
while ($data = dbarray($result)) {
echo "<tr>\n<td><a href='".BASEDIR."profile.php?lookup=".$data['user_id']."'>".$data['user_name']."</a></td>
<td align='right'><a href='".FUSION_SELF."?step=delete&rowstart=$rowstart&user_id=
".$data['[color=orange]user_id[/color]']."' onclick='return
DeleteMember()'>".$locale['nl402']."</a></td>
</tr>\n";
</tr>\n";
while ($data = dbarray($result)) {
echo "<tr>\n<td><a href='".BASEDIR."profile.php?lookup=".$data['user_id']."'>".$data['user_name']."</a></td>
<td align='right'><a href='".FUSION_SELF."?step=delete&rowstart=$rowstart&user_id=
".$data['[color=red]newsletter_sub_user[/color]']."' onclick='return
DeleteMember()'>".$locale['nl402']."</a></td>
</tr>\n";
I attached the complete corrected infusion