**Background**
As a target of harassment, I want to restrict which user groups can send me email (e.g. choose between all users, require autoconfirmed access or admins). If sending email is disallowed this way, the "email this user" link should not be displayed and visiting Special:EmailUser/Foobar should display the "This user has chosen not to receive email from other users." message.
----
**On-wiki specification**
[[https://meta.wikimedia.org/wiki/Community_health_initiative/Allow_users_to_restrict_which_user_groups_can_send_them_direct_emails |Meta — Community health initiative/Allow users to restrict which user groups can send them direct emails]]
----
**Discussions**
* [[ https://meta.wikimedia.org/wiki/Grants:IdeaLab/Allow_users_to_restrict_who_can_send_them_email | IdeaLab ]]
* [[ https://meta.wikimedia.org/wiki/2016_Community_Wishlist_Survey/Categories/Miscellaneous#CW2016-R093 | 2016 Wishlist ]]
----
**Proposed solution #1**
// Note: this is all a Work-In-Progress! Please provide feedback in the comments below. //
* In the 'Email options' of the 'User profile' tab of Special:Preferences, replace the "Enable email from other users" tickbox with a dropdown
** Label: Allow direct emails from:
** The options in the dropdown should be what is in the table below
* If a user **is in** the selected usergroup, the Special:EmailUser feature should work as it currently does today.
* If a user **is not in** the selected usergroup:
** They should not see the "Email this user" link in the left rail on userspace pages
** If they directly navigate to Special:EmailUser/Foobar they should see the standard error message of "[[ https://commons.wikimedia.org/wiki/File:Special-EmailUser_screenshot_if_the_feature_is_disabled_by_a_user.png | This user has chosen not to receive email from other users ]]" as if the other user had the entire preference disabled
* The default for new accounts created when their email address is confirmed should be 'Autoconfirmed users'
* All existing user preferences should be mapped to the corresponding new preference, per what is documented in the table below.
* This should be customizable per wiki by users with the editinterface permission
** The options in the dropdown
** The default for new accounts
* Regardless of selection, the Prohibit list (T138166) should still be respected
| **Dropdown option label** | **Allows email from** | **Map from existing preferences**
| Nobody | no users — should behave as when current tickbox is unticked | Unticked
| All users | all users with verified email addresses — should behave as when the current tickbox is ticked | Ticked
| Autoconfirmed users | all users with verified email addresses and in the autoconfirmed usergroup | n/a
| Administrators | all users with verified email addresses and in the administrators usergroup | n/a
{F9384420}
----
**Proposed solution #2**
// Note: this is all a Work-In-Progress! Please provide feedback in the comments below. //
* In the 'Email options' of the 'User profile' tab of Special:Preferences, add a new tickbox preference
** Label: Allow direct emails from brand-new users (learn more)
** 'learn more' should link to a help/project page (TBD)
* If the user has this preference enabled (ticked) the Special:EmailUser feature should work exactly as it does today.
* If the user has this preference disabled (unticked):
** Users in the autoconfirmed group should be able to use the Special:EmailUser feature as it exactly does today.
** Users **not** in the autoconfirmed group:
*** should not see the "Email this user" link in the left rail on userspace pages
*** should see the standard error message of "[[ https://commons.wikimedia.org/wiki/File:Special-EmailUser_screenshot_if_the_feature_is_disabled_by_a_user.png | This user has chosen not to receive email from other users ]]" as if the other user had the entire preference disabled when they directly navigate to Special:EmailUser/Foobar
* The default for new accounts created when their email address is confirmed should be unticked (off)