**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.
----
**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 ]]
----
**Acceptance criteria**
// 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
----
**Wireframe**
{F9384420}