We originally configured Simplenews to run via cron. Something broke and now every time we run cron, it attempts to send out a newsletter. Our members are furious, and we're terrified of running cron (which is not, thankfully, automated yet). If there's a sending of a newsletter stuck in a queue somewhere, how do we get rid of it? Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sutharsan’s picture

Status: Active » Fixed

If you are looking for a one time fix, I guess a solution directly in the database is no problem.
In the simplenews_mail_spool table holds data for all the newsletters (recently send and) to be send.
The status field is the individual email status. 1 = pending; 2 = send. Records with status = 1 will be (re-)send at the next cron run. Change a '1' to '2' and the record is marked send.

Note that this queue is also used when sending without cron. When you send a newsletter and there are records with status = 1 still in the spool they will be send too.

In future releases I hope to create an interface for this spool, but currently none is available.

labourstart’s picture

Thanks very much -- let's hope this solves the problem and we can use simplenews.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

emdesign’s picture

Version: 6.x-1.x-dev » 5.x-1.2

I am experiencing the same problems as the original poster. Our site is using 5.x-1.2. Does the simplenews_mail_spool fix work for this version as well? I did not install Drupal, so I'm having trouble finding the simplenews_mail_spool table. Can you tell me where to locate it?

hansrossel’s picture

To stop a newsletter that is sending you can use the following code:

db_query("UPDATE  {simplenews_newsletters} SET s_status = 0 WHERE s_status = 1"); //This sets the status of all newsletters that are sending (1) back to unsent (0)
db_query("TRUNCATE TABLE {simplenews_mail_spool}"); //This empties the queue of emails that are in the current batch that is sending
sliveroix’s picture

where to post these codes?

miro_dietiker’s picture

Use e.g. drush eval in command line.
Or you put the SQL directly into e.g. phpmyadmin and remove curly braces.

enkara’s picture

I don't have the simplenews_mail_spool table, but it would be really nice to have a button to stop the newsletters

miro_dietiker’s picture

Title: How to stop sending out a newsletter? » How to stop sending out a newsletter? Display progress, add UI
Version: 5.x-1.2 » 7.x-1.x-dev
Category: support » feature
Priority: Critical » Normal
Status: Closed (fixed) » Active

Reopening this issue as a feature request for Drupal 7 development.

The lack of this feature in general is very limiting.

Berdir’s picture

Title: How to stop sending out a newsletter? Display progress, add UI » Stop sending a newsletter

Closed #1271242: Stop sending Newsletters as a duplicate.

Related to #1169990: Improve usability and displayed information on the newsletter tab which is about general/UX improvements to the newsletter tab, so updating the issue title

Berdir’s picture

Title: Stop sending a newsletter » Stop sending action on newsletter overview

Separating this from the previously mentioned issue, a stop button will be added there, this is only about adding a corresponding action on the newsletter overview.

Berdir’s picture

Assigned: Unassigned » corvus_ch
Jelmer85’s picture

Holy shit, thank you so much. You saved my life :D Sort of...

(I simply added this to a node with the PHP filter enabled. After having backed up my Database of course)

miro_dietiker’s picture

Issue summary: View changes
Issue tags: +8.x release target

Since this is such a severe issue we'd like to make the world better and avoid sending spam. ;-)
Stop is simply a major UX requirement.

russellb’s picture

There seem to have been some changes since the code fragment was posted above. I've just been through this process on simplenews 7.x-1.1 and changed the fragment as follows:

<?php
db_query("UPDATE  {simplenews_newsletter} SET status = 0 WHERE status = 1");
//This sets the status of all newsletters that are sending (1) back to unsent (0) 	

db_query("TRUNCATE TABLE {simplenews_mail_spool}");
//This empties the queue of emails that are in the current batch that is sending
?>

+1 for this being a very desirable feature in the UI!

miro_dietiker’s picture

The feature "Stop sending!" should introduce a new state "Aborted" for a newsletter.
Also, first it's not about deleting the queue. It's about stop processing it.
We might exclude "aborted" newsletters in cron. Possibly, we should also update the spool records states to "aborted".
And sure, all these commands should eat newsletter issue nid to properly limit scope.

Later we could offer a "Purge" and a "Resume" button...

russellb’s picture

Hi Miro,

That sounds great! Equally a simple stop & purge link would be welcome as an incremental improvement, pending development of a full stop, purge and resume system.

miro_dietiker’s picture

Here we go!
A first super minimalistic version of the stop button has been implemented in 8.x through the node newsletter tab while sending.
Looking forward to further improvements.

Berdir’s picture

Issue tags: -8.x release target

#2413995: Replace newsletter issue overview with views will add this to the newsletter overview, so removing the 8.x tag :)

corvus_ch’s picture

Assigned: corvus_ch » Unassigned
Alex2.0’s picture

Is this feature already implemented in 7.x? I can't find it anywhere....

miro_dietiker’s picture

No and that's why the issue is still open as a feature request.

Alan D.’s picture

A kill switch if a critical feature of a newsletter system, cause when they go wrong, they go really badly wrong.

Only personally had the misfortune of this happened twice, 12 years ago that nearly resulted in legal action against the company (crappy custom inhouse cms was to blame) and today. About 1,000 emails sent to students from around the world before it was picked up and blocked (luckily using SMTP, so it was easy to disable emails for the time being)

What is the best way to do this without access to the command line / db in Drupal 7?

Deploy russellb solution into an update script? Or would simply deleting the newsletter node be enough?

miro_dietiker’s picture

@Alan D. My words, i would fully support its criticalness. But well, you know, it really can't be that critical!
I proposed its implementation so many times to customers or sprint goals. But no one supported its implementation.. So we left this open as a challenge to the community.

And then the team found motivation to still do it for Drupal 8 in a rush of implementing "features that should have been part of Simplenews since day one"... But the energy didn't reach for a D7 backport.

If you want to bring it into an installation, checkout D8 and implement a kill switch button and a submit handler. And provide the patch here. It's basically the same complexity as writing an update hook...

Alan D.’s picture

I was simply querying a simple workaround to avoid creating additional costs to the client, prefer to be working on more constructive outcomes for them rather than chasing issues ;)

But did want to emphasis the negatives of not having this!

Alan D.’s picture

A kick start if anyone needs it. Single client using this on an old branch, and no idea what direction D8 took, so tmp solution for old version.

Adds new form with a purge option on node/%/simplenews

Action flags as sent, purges the queue and unpublishes the node. No conditional actions.

[edit]
I ended up removing the published node step as this confused the clients workflow, since they normally publish nodes to trigger the newsletter getting sent. If they want to hide it, they can manually handle that!