Manual:sendBulkEmails.php

From Linux Web Expert

sendBulkEmails.php is a MediaWiki maintenance script found in WikimediaMaintenance. It can be used to send an email to given list of Users. The maintenance script will send emails using User::sendMail. Bounce tracking will be automatically taken care of by BounceHandler if installed for the wiki.

Features

  • Read message body from a file
  • Read recipients from a file, one per line
  • Only send to accounts with confirmed email addresses
  • Only send to accounts that have not opted out of email contact from other users
  • Optional: check users against an opt-out list maintained on-wiki
  • Optional: set a From: address based on a User's account
  • Optional: set a Reply-To: address based on a User's account
  • Track bounces and unconfirm user emails if needed when BounceHandler is installed

Arguments

--to List of users to email, one per line (file)
--subject Email subject (string)
--body Email body (file).
--from Email sender (username). Optional.
--optout wikipage containing list of users to exclude from contact (title). Optional.
--reply-to Reply-To address (username). Optional.
--delay Time to wait between emails (seconds). Default is 5 seconds.
--dry-run Do not send emails.

Usage

$ mwscript extensions/WikimediaMaintenance/sendBulkEmails.php --wiki=labswiki \
  --subject "This is the email subject" \
  --body "/path/to/file/containing/body.txt" \
  --from "UserSendingTheEmail" \
  --to "/path/to/file/containing/users.txt" \
  --reply-to "UserReceivingReplies" \
  --optout "Title_of_Opt-out_page"