Page MenuHomePhabricator

Make maintenance script for sending annual survey emails
Closed, ResolvedPublic

Description

It would be nice to have a maintenance script for sending batches of email messages for the Tool Labs annual survey and other similar one-off mailing list events. This topic comes up from time to time and there is always a random scramble to find a way to send the messages that won't result in a higher than normal spam classification or getting the WMF mail relays put on a bouncelist of some kind.

Event Timeline

bd808 created this task.Oct 20 2016, 7:53 PM
Restricted Application added a project: Cloud-Services. · View Herald TranscriptOct 20 2016, 7:53 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
bd808 added a comment.Dec 1 2016, 9:42 PM

This script should make sure that bounces come back to the wiki so bounce handlers are notified.

It would be extra awesome if we added a bulk-mailing opt-out user preference and a special page that toggled it so that the emails could include a List-Unsubscribe header pointing to the special page. The "If you do not wish to receive future annual survey emails from the Tool Labs team, uncheck 'Enable email from other users'" item from the 2015 and 2016 surveys is not user friendly at all.

scfc triaged this task as Low priority.Feb 16 2017, 10:37 PM
scfc moved this task from Triage to Backlog on the Toolforge board.
bd808 added a subscriber: Legoktm.Oct 3 2017, 5:05 AM

@Legoktm would it be crazy to implement the functionality of https://www.mediawiki.org/wiki/Extension:MassMessageEmail directly in https://www.mediawiki.org/wiki/Extension:MassMessage as something that could be toggled per-message if allowed by wiki config? This would give a UI for bulk mailing and an opt-out system basically for basically free.

Tgr added a subscriber: Tgr.Oct 6 2017, 6:00 AM

Well, you'd have to opt out from all mass messages, which seems a bit overboard (although in general the ability to send email or even better Echo notifications with MassMessage would be nice). Why not use the Newsletter extension for this? Seems like the exact use case it was meant for.

bd808 added a comment.Oct 6 2017, 4:19 PM

Why not use the Newsletter extension for this? Seems like the exact use case it was meant for.

It's not clear to me if Newsletter can send an email to a list that is not content also published on the wiki.

A "newsletter" is defined as a publication that has a name, a wiki home page, and a single or central wiki page for each issue or edition. -- Extension:Newsletter

What I really want is:

  • Maintenance script that can send an email to given list of wiki account holders
  • Ability to check for an 'opt-out' signal for on each targeted account before sending
  • Track bounces and unconfirm user emails if needed
  • (bonus) easy means to 'opt-out' from future emails on the same topic
  • (bonus) easy means to 'opt-out' of all mass emails sent in a similar way

In this very specific case I know how to gather a list of all Toolforge members from OpenStack Keystone as either usernames or email addresses. Then I need to remove a set of users/email addresses who have explicitly opted-out of past survey announcements. The email will have a link to a survey form that in this case is not customized per-recipient, but I don't want that link posted on a wiki or a mailing list because that pollutes the survey pool. The trivial way to do the opt-out list would be to have people add their account names to a list on a specific wiki page. It could also be done with a magic category like MassMessage does. The big difference from Newsletter is that the list I want is opt-out rather than opt-in.

I think I can make all of this myself by creating a maintenance script that takes as input:

  1. wiki page containing a list of users to contact
  2. wiki page (or category?) containing a list of opt-ed out users for this message type
  3. wiki page (or category?) containing a list of globally opt-ed out users for this maintenance script
  4. file containing message to send

Mass message already handles all of these things I think. The difference is that it delivers the message as a talk page post rather than an email. On irc yesterday @Legoktm thought that making the email ability available as a MassMessage maintance script could be reasonable:

[04:07:19] <bd808> legoktm: is my idea at https://phabricator.wikimedia.org/T148783#3652887 to make it optional for MassMessage to send emails instead of talk page pings crazy?
[04:07:39] <bd808> I don't want to start on code if it is :)
[04:11:20] * legoktm looks
[04:11:32] <legoktm> it's not too crazy
[04:12:10] <legoktm> but I don't think it should be possible to send random emails via a web UI, it should be started via CLI script
[04:12:24] <legoktm> but you can still use a mass message input list for it
[04:13:06] <legoktm> so I think a maint script that gets a list of users from a MM input list and sends them emails would be acceptable
madhuvishy renamed this task from Make maintance script for sending annual survey emails to Make maintenance script for sending annual survey emails.Oct 10 2017, 3:49 PM
madhuvishy removed a project: Cloud-Services.
bd808 added a comment.Oct 30 2017, 9:47 PM

What I really want is:

  • Maintenance script that can send an email to given list of wiki account holders
  • Ability to check for an 'opt-out' signal for on each targeted account before sending
  • Track bounces and unconfirm user emails if needed
  • (bonus) easy means to 'opt-out' from future emails on the same topic
  • (bonus) easy means to 'opt-out' of all mass emails sent in a similar way

I've stared at the code of Newsletter and MassMessage for a while now. I think that I could probably find a way to twist either one into doing most of what I want for the Toolforge survey emails, but it doesn't seem to be a really great fit for either extension. I think that the "easiest" thing is going to be to write a custom maintenance script that does what I need it to do today and put that somewhere where others can find it and iterate on the functionality for other uses.

Here's what I'm planning on supporting:

  • --subject STRING: email subject
  • --body FILE: email body
  • --to FILE: file of usernames to deliver message to
  • --optout TITLE: wikipage containing list of users to exclude from contact

The maintenance script will send emails using User::sendMail. Bounce tracking will be automatically taken care of by BounceHandler if installed for the wiki.

The only criteria from the list this does not cover is (bonus) easy means to 'opt-out' of all mass emails sent in a similar way.

You could create a page like https://meta.wikimedia.org/wiki/Wikimedia_Foundation_nomail_list (used for board elections) on wikitech to serve as the opt-out listing?

bd808 added a comment.EditedOct 30 2017, 9:58 PM

You could create a page like https://meta.wikimedia.org/wiki/Wikimedia_Foundation_nomail_list (used for board elections) on wikitech to serve as the opt-out listing?

Yeah, I started https://wikitech.wikimedia.org/wiki/Annual_Toolforge_Survey/Opt_out for this same sort of opt-out process.

Why not use the Newsletter extension for this? Seems like the exact use case it was meant for.

It's not clear to me if Newsletter can send an email to a list that is not content also published on the wiki.

Correct. The content delivered via the Extension:Newsletter is purely a link to a local wikipage, it cannot be an external or interwiki link. E.g. screenshot and the link in there is to a page on mw.o. If we try to use an external link, we get an error message.

What I really want is:

It sounds like MassMessageEmail will indeed be the most feasible current solution.
There are 3 methods of creating MassMessage delivery lists, and the first is the easiest for someone to "opt-out of". You change the contentmodel of the wikipage to MassMessageListContent and it gives all entries a one-click (remove) link -- see example at https://en.wikipedia.org/wiki/Wikipedia:Wikipedia_Signpost/Subscribe#Add_pages (ignore the massive description above)

Change 387516 had a related patch set uploaded (by BryanDavis; owner: Bryan Davis):
[mediawiki/extensions/WikimediaMaintenance@master] Maintenance script for sending bulk emails

https://gerrit.wikimedia.org/r/387516

Change 387516 merged by jenkins-bot:
[mediawiki/extensions/WikimediaMaintenance@master] Maintenance script for sending bulk emails

https://gerrit.wikimedia.org/r/387516

bd808 claimed this task.Nov 28 2017, 8:32 PM
bd808 edited projects, added cloud-services-team (Kanban); removed Patch-For-Review.