Hi,

it's said in the doc: The Forward form only allows one email recipient to be entered at a time to reduce spam.
...but i would like to allow multiple recipients.

Is there a way to allow that again ?

Thanks.

Seb

Comments

Seb.R created an issue. See original summary.

Jasperh’s picture

Version: 8.x-2.0-rc1 » 8.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new13.69 KB

This patch adds the possibility to send a mail to multiple recipients.

The site builder can change the maximum allowed recipients in the settings, which defaults to one. When multiple recipients are allowed the input field for the recipients changes from a email field to a textarea. Where the user can enter one or more recipients separated by: space, komma, semicolon or enter. The input is checked for incorrect or duplicate email addresses and wether the number of recipients is higher than the maximum allowed number.

To preserve backwards compatibly the default value only allows one recipient and everything will look and work the same.

The patch also contains a update hook which adds the default value for the new variables.

john.oltman’s picture

That's great @jasperh I'll take a look within the next few days. I have some other issues to address as well. It is probably time for a new release before the end of the year.

sutharsan’s picture

I mentored Jasperh when writing this code. The solution is solid and code looks good, except for the comments below.

I'm not particularly fond of the ForwardFormBuilder and all the services that are passed around to the form, but I did not really investigate that as it is existing code.

  1. +++ b/config/install/forward.settings.yml
    @@ -27,3 +27,5 @@ forward_bypass_access_control: 0
    \ No newline at end of file
    

    Please add an empty line at the end of this document.

  2. +++ b/forward.install
    @@ -107,3 +107,14 @@ function forward_schema() {
    \ No newline at end of file
    

    Please add an empty line a the end of this document.

  3. +++ b/src/Form/ForwardForm.php
    @@ -428,6 +467,18 @@ class ForwardForm extends FormBase implements BaseFormIdInterface {
    +    $recipients = $this->splitEmailAddresses($form_state->getValue('recipient'));
    +    if (count($recipients) > $this->settings['forward_max_recipients']) {
    

    Will "empty" input of multiple spaces, or new lines get detected? (I did not test this) or is it detected by the default required field validation?

sutharsan’s picture

Status: Needs review » Needs work

Needs work...

john.oltman’s picture

I am wrapping up a different issue for Forward, once I get that issue committed I will try this out, sorry for the delay.

Jasperh’s picture

Status: Needs work » Needs review
StatusFileSize
new14.29 KB
new2.01 KB

Added empty lines and correct field validation for when the input only consists of whitespaces.

john.oltman’s picture

Patch needs to be re-rolled against latest Dev.

john.oltman’s picture

Status: Needs review » Needs work
Jasperh’s picture

Status: Needs work » Needs review
StatusFileSize
new13.09 KB

Patch #7 re-rolled against latest dev.

john.oltman’s picture

Added to rc2

john.oltman’s picture

Status: Needs review » Fixed
john.oltman’s picture

Title: Re-allow multliple recipents » Re-allow multiple recipients
john.oltman’s picture

@Jasperh please install RC2 release and let me know if that works for you. If it does, I will do a general release of 8.x-2.2

Jasperh’s picture

@john.oltman everything works fine for me

Status: Fixed » Closed (fixed)

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

dww’s picture

Alas, this broke the submit handler for the forward form:

#3034561: Undefined variable: recipient in Drupal\forward\Form\ForwardForm->submitForm()

Anyone who worked on this issue is invited to help out over there.

Thanks!
-Derek

dww’s picture