Problem/Motivation

After submitting a contact form the message "Your message has been sent." is shown to the user even in the case that the emails were failed to send. The correct error message about the failure of sending the mail itself appears separately.

Contact form error messages

Proposed resolution

Make the message conditional so that it displays an error in case the mail is not sent.

In case the user checks the "send yourself a copy" checkbox:

In case the user doesn't check the "send yourself a copy" checkbox:

Remaining tasks

Everything.

User interface changes

Message string will change.

CommentFileSizeAuthor
#90 2348119-90.patch4.15 KBcasey
#88 2348119-88.patch4.17 KBcasey
#71 wrong_message_displayed-2348119-71.patch7.11 KBgoogletorp
#66 interdiff-test-class.txt1.77 KBgoogletorp
#66 interdiff.txt6.81 KBgoogletorp
#66 wrong_message_displayed-2348119-66.patch7.33 KBgoogletorp
#66 wrong_message_displayed-2348119-66-TEST.patch2.88 KBgoogletorp
#60 interdiff.txt6.65 KBgoogletorp
#60 wrong_message_displayed-2348119-60.patch6.46 KBgoogletorp
#53 2348119-wrong-messages-displayed.patch8.25 KBRavindraSingh
#50 Screen Shot 2015-05-20 at 6.23.20 AM.png149.91 KBRavindraSingh
#50 Screen Shot 2015-05-20 at 6.20.46 AM.png120.01 KBRavindraSingh
#49 wrong_message_displayed-2348119-49.patch8.31 KBgoogletorp
#49 interdiff.txt799 bytesgoogletorp
#47 after.png92.86 KBRavindraSingh
#47 before.png163.38 KBRavindraSingh
#46 contact-form-messages.png87.31 KBadriancotter
#42 wrong_message_displayed-2348119-42.patch8.3 KBgoogletorp
#42 interdiff.txt3.89 KBgoogletorp
#41 wrong_message_displayed-2348119-41.patch4.41 KBgoogletorp
#38 Reproduce-bug-test-case-2348119-38.patch4.24 KBsubins2000
#30 Screen Shot 2014-10-03 at 2.41.20 PM.png43.46 KBkulcsi
#29 mail-error-message.patch3.89 KBhexblot
#25 status_message_as_error.png18.81 KByannisc
#25 correct_error_message.png27.77 KByannisc
#18 Wrong-message-displayed-2348119-18.patch3.88 KBrpayanm
#15 Wrong-message-displayed-2348119-15.patch3.51 KBrpayanm
#8 2348119-1.patch3.01 KBhexblot
#6 Wrong-message-displayed-2348119-6.patch1.88 KBrpayanm
#3 Screenshot 2014-10-01 14.23.23.png51.75 KBbatigolix
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kugta’s picture

Issue summary: View changes
batigolix’s picture

Issue tags: +Amsterdam2014, +Novice
batigolix’s picture

Issue summary: View changes
FileSize
51.75 KB
batigolix’s picture

Issue summary: View changes
batigolix’s picture

Issue summary: View changes
rpayanm’s picture

Status: Active » Needs review
FileSize
1.88 KB

trying...

Status: Needs review » Needs work

The last submitted patch, 6: Wrong-message-displayed-2348119-6.patch, failed testing.

hexblot’s picture

FileSize
3.01 KB

This is a different approach than the one used in the patch provided by rpayanm.

I think there's a bit of clarification required as to the way to proceed with this - to my understanding, at least the issue should be solved in the \Drupal\contact\MessageForm class (the one that also prints out the success message), which cannot get the error message since \Drupal\contact\MailHandler->sendMailMessages() does not return the message (or any other indication that something went wrong).

In addition, it seems that MailHandler->sendMailMessages() can potentially send up to 3 emails ( requested, copySender and auto reply as documented in the interface). Since an error here would indicate that our mailing system does not accept emails to send, should the process be aborted after the first failure ?

Finally, there's a bit of a naming conflict here - $message, in the scope of \Drupal\contact\MessageForm is an instance of \Drupal\contact\MessageInterface , whereas in scope of \Drupal\contact\MailHandler it is an array of the actual message data.

I've rolled a patch that does the following (in a way that I'm not proud of, please suggest a better way) :
* assigns the return value of MailManager->mail() in MailHandler->sendMailMessages()
* checks the result value on every step of the way, and does not make an attempt to send more emails if the first failed
* passes the final value on to the MessageForm, which then uses it to decide whether to tell the user his mail has been sent.

@rpayanm: in addition to the intended result, you seem to have an unintended change in your patch for the language module.

Hope I'm making some sense, please advise.

rpayanm’s picture

Status: Needs work » Needs review

@hexblot Nice comment and thank you for say me my error, I mix two patches hehe ;)

I like you patch, you miss change the status to "needs review", for the bots make the dirty work! :D

Greetings.

rpayanm’s picture

RTBC +1

larowlan’s picture

larowlan’s picture

+++ b/core/modules/contact/src/MailHandler.php
@@ -116,18 +116,18 @@ public function sendMailMessages(MessageInterface $message, AccountInterface $se
+    $message_data = $this->mailManager->mail('contact', $key_prefix . '_mail', $to, $recipient_langcode, $params, $sender_cloned->getEmail());
...
+      $message_data = $this->mailManager->mail('contact', $key_prefix . '_copy', $sender_cloned->getEmail(), $current_langcode, $params, $sender_cloned->getEmail());
...
+      $message_data = $this->mailManager->mail('contact', 'page_autoreply', $sender_cloned->getEmail(), $current_langcode, $params);

@@ -144,6 +144,8 @@ public function sendMailMessages(MessageInterface $message, AccountInterface $se
+    return $message_data['result'];

I think we should keep sending even if an earlier message failed and that the return should be keyed by the type. ie. we add three constants to the class for each of the types MESSAGE_RECIPIENT, MESSAGE_COPY, MESSAGE_REPLY and then the return is and array of those results. If two were called, then we return an array with two results, three mails = array with three results and so on.
Then the code in the form just checks over the array to see that $message_results[MailHandler::MESSAGE_RECIPIENT] is TRUE and shows the user the success message in that case.

Also we need tests here to prevent a regression - good news is we have PHPUnit for the MailHandler class so can adapt it. Happy to work on tests - let me know.

larowlan’s picture

Issue tags: +Needs tests
rpayanm’s picture

Assigned: Unassigned » rpayanm

Let me try... :)

rpayanm’s picture

Assigned: rpayanm » Unassigned
FileSize
3.51 KB

I got a dude, for example:
I use the contact form and I check "Send yourself a copy", but when Drupal send the message occur this:

  • Send email to the recipient(s).....ok
  • Send a copy to the user..............fail
  • Send an auto-reply......................fail

Drupal show a successful message to the user, but the user never get a copy of this.

Anyway, here the patch you tell me what you think.

Grettings.

larowlan’s picture

  1. +++ b/core/modules/contact/src/MailHandler.php
    @@ -144,6 +159,8 @@ public function sendMailMessages(MessageInterface $message, AccountInterface $se
    +    return $message_results[MailHandler::MESSAGE_RECIPIENT]['result'];
    

    I think we should return all of them, it make the mail-handler class more useful for other consumers

  2. +++ b/core/modules/contact/src/MessageForm.php
    @@ -188,10 +188,11 @@ public function preview(array $form, FormStateInterface $form_state) {
    +    if($this->mailHandler->sendMailMessages($message, $user)) {
    

    which means we'd need to store and check the response here of course.

Still needs tests

hexblot’s picture

I don't think there's a point in checking individual cases -- this is why:
if you get an error, it is not because the email address was wrong, or something trivial or user dependent - it is because your mail server was unreachable, not accepting mail, or otherwise wrongly configured.

This status is basically inherited from PHP's mail() (in the default case) which reports that the return value is :

Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

That, to my mind, means that the first mail could not be passed on to the mail server for whatever reason, and cannot be a reason that will change in the span of this request. Feel free to correct me if I'm wrong, but even in every implementation I've encountered in D7 (SMTP etc) failure at this level is not recoverable, and state will not change simply because it means that you could not properly talk to the mail server (not that something was wrong with the message).

rpayanm’s picture

Nishruu’s picture

Currently testing the patch.

Nishruu’s picture

Status: Needs review » Reviewed & tested by the community

I think the #8 hexblot's patch solves the issue in a better way. It seems very unlikely that the mail will fail in a case and not the others, and by using this patch we only have one error message (the #18 create multiple messages for what we think is the same error).

yannisc’s picture

Status: Reviewed & tested by the community » Needs work

#18 solves the problem when I don't select "send yourself a copy", as I get the error: Unable to send email. Contact the site administrator if the problem persists.
Screenshot: http://cl.ly/image/2f392Z3x0317

When I check the "send yourself a copy" option, I get two errors:

Unable to send email. Contact the site administrator if the problem persists.
Your message copy has been sent.

Screenshot: http://cl.ly/image/2X1O373V3p35

I think the second message should be green, as it's not an error, it's the success message.

So, I mark the issue as needs work.

kugta’s picture

@yannisc, the success message not being green is a different issue here: drupal_set_message inherits previous style if set to 'status'

hexblot’s picture

Status: Needs work » Needs review
FileSize
3.88 KB
13.94 KB

This is actually two different problems -
* one is with the core Mail class, which prints to the screen messages without being asked for
* the other is with what the contact modules does in ways of error handling.

This issue should focus on the contact module side of things, and here we should print a message about an error that occurred. Ideally, we should have a way to tell the core Mail module to not output on the screen, but this issue is not the place to address it.

In the patch I'm attaching:
* extra constant is removed ( auto reply is never checked )
* try to only have one error / success message (if normal message has issues, stop)
* if the copy was selected and sent, check it and print it individually. Only when the edge case of the normal message being sent and the copy not being sent will you get two error messages, which should be less than one in a million chance.
* fixed the fatal error thrown when an error occurred.

larowlan’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/contact/src/MailHandler.php
    @@ -23,6 +23,16 @@ class MailHandler implements MailHandlerInterface {
    +   * Index to identify the result of the message recipient.
    +   */
    +  const MESSAGE_RECIPIENT = 'recipient';
    +
    +  /**
    +   * Index to identify the result of the message copy.
    +   */
    +  const MESSAGE_COPY = 'copy';
    +
    

    we lost auto-reply here

  2. +++ b/core/modules/contact/src/MessageForm.php
    @@ -188,10 +188,24 @@ public function preview(array $form, FormStateInterface $form_state) {
    +    if (isset($message_results[MailHandler::MESSAGE_COPY])) {
    +      if (!$message_results[MailHandler::MESSAGE_COPY]['result']) {
    +        drupal_set_message($this->t('Your message copy has been sent.'));
    +      }
    +      else {
    +        drupal_set_message($this->t('Your message copy has not been sent.'), 'error');
    +      }
    +    }
    

    I don't think this is needed

still needs tests

yannisc’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community
FileSize
27.77 KB
18.81 KB
yannisc’s picture

Status: Reviewed & tested by the community » Needs work

Sorry for the last change.

yannisc’s picture

Issue summary: View changes
hexblot’s picture

@larowlan: we lost auto reply because is neither checked or there is much sense in checking it (the current user should not be notified about some other users setting failing to work as expected). If you think it's best to have it there for completeness sake, let me know.

In addition, the second bit of code about the copy is there to catch the case where the normal case was sent but the copy was not (VERY edge case, but still).

@yannisc : As for the multiple error messages - as written in #23, the first message is written by Mail in core, whereas the second is written by Contact module, for which this issue is about. Mentors here are investigating on whether core mail should actually print its own messages on screen, but on either case it's best to have a friendly message related to our specific case for users, not just the system error above ( in my opinion ).

Contact should have a message about failing, regardless of core. It should find a way to tell core Mail to NOT print a message, but that's an issue for core Mail, not the Contact module.

Let me know if we need additional changes to the code.

hexblot’s picture

Status: Needs work » Needs review
FileSize
3.89 KB

Re-uploading patch file, seems to not have been sent for testing.

kulcsi’s picture

I've tested the patch #29
The result is the same in case the user checks the "send yourself a copy" checkbox, and in case the user don't checks it.
Here is the screenshoot:
screenshoot
I think the initial problem is fixed.

Nishruu’s picture

Status: Needs review » Reviewed & tested by the community

In both case the mail sent to the user failed, so there is and should be an error because when you install Drupal, the recipient for the mail isn't filled by default.
In case both mails (original and copy) failed, there's only one message (no repetition), which I think is a good idea.

For me the #30 is RTBC.

On another subject, we should create an issue about the first message (see #30 "Unable to send email...") which is generated by core (not contact module). @hexblot and me agreed that Core shouldn't print directly this message. I will post another issue about that if needed.

hexblot’s picture

@Nishruu - already posted an issue here

hexblot’s picture

@Nishruu - already posted an issue here

batigolix’s picture

larowlan’s picture

Status: Reviewed & tested by the community » Needs work

Needs tests
Also the check for copy shouldn't happen unless they tick that box.

yannisc’s picture

@Nishruu, regarding the issue that after Drupal installation finishes, the contact form misses the recipient email, I opened an issue here: #2349651: Default contact form does not send email as email recipient is not set during the installation.

hexblot’s picture

@larowlan: Copy is checked in MailHandler ( uses $message->copySender() which is a boolean ) , and the result value is only set there if it was used . That's what the isset() in MessageForm is about.

Will add tests for all the above cases as well.

subins2000’s picture

Here is a patch of the test file that reproduces this bug

larowlan’s picture

Status: Needs work » Needs review
disasm’s picture

Lets combine #29 and #38. Lets do some manual testing to determine if this issue is reproducable still in 8.0.x. If it is, lets fix the test in #38 so it fails properly without the code in #29 and passes with it.

googletorp’s picture

Fixed the test, so that it now fails on the behavior we want to avoid.

googletorp’s picture

Combined patch from #41 with patch from #29.

The test should now pass. The patch from #41 proves that the this is reproducible, so removed manual test tag, along with other outdated tags.

The last submitted patch, 41: wrong_message_displayed-2348119-41.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 42: wrong_message_displayed-2348119-42.patch, failed testing.

Status: Needs work » Needs review
adriancotter’s picture

Issue summary: View changes
FileSize
87.31 KB

Testing today here at DrupalConLA
Using an invalid email for the sender this is what I got (screenshot below)

The checkbox for emailing a copy was checked.

This is a confusing user experience. I'm not sure if this relates to having two messages from different systems, or if this is one message for the email being sent, and the other for the message copy being sent to the sender. If the latter, one of the messages should reflect which email did or did not get sent (we were unable to email you a copy of the email).

RavindraSingh’s picture

FileSize
163.38 KB
92.86 KB

Patch added in #42 has a lots of improvement. but still there are few thing which I think needs to be fix in case of failure.
Before :
Before

After :
After

In after screen you see there are two messages which says same statement.

" Unable to send email. Contact the site administrator if the problem persists.
  Your message has not been sent.
"

It should be:

We are unable to send email. Please contact the site administrator if the problem persists.
 
RavindraSingh’s picture

Status: Needs review » Needs work
googletorp’s picture

Status: Needs work » Needs review
FileSize
799 bytes
8.31 KB

I Removed the custom error message and left a comment, since at some point maybe the mailhandler wont create the error message anymore.

RavindraSingh’s picture

Awesome work @googletorp.
Patch added in #49 works perfactly. Moving it to RTBC with latest output.

Before

After

RavindraSingh’s picture

Status: Needs review » Reviewed & tested by the community
anavarre’s picture

  1. +++ b/core/modules/contact/src/Tests/NotExistEmailContactTest.php
    @@ -0,0 +1,128 @@
    +   * Tests messages displyed when can't send contact mail.
    

    Nit: s/displyed/displayed

  2. +++ b/core/modules/contact/src/Tests/NotExistEmailContactTest.php
    @@ -0,0 +1,128 @@
    +    // Unable to send email message should be displayed, but not the your
    

    Needs rewording.

  3. +++ b/core/modules/contact/src/Tests/NotExistEmailContactTest.php
    @@ -0,0 +1,128 @@
    +   * @param string $id
    

    Wouldn't that be an int?

RavindraSingh’s picture

@anavarre, I have fixed issues in updated patch. and Not adding interdiff because just 2 comments line changed.

1. Fixed
2. Removed the lost part of the statement which was not making sence
3. It should be same as it is because $id contains alpha numeric. eg
$this->addContactForm($id = Unicode::strtolower($this->randomMachineName(16)),

RavindraSingh’s picture

Status: Reviewed & tested by the community » Needs review
googletorp’s picture

Status: Needs review » Reviewed & tested by the community

Things from #52 has been addressed, think this is RTBC now.

RavindraSingh’s picture

Nice coordination, Credit goes to all.

larowlan’s picture

Priority: Minor » Normal
Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/contact/src/MailHandler.php
    @@ -116,15 +126,15 @@ public function sendMailMessages(MessageInterface $message, AccountInterface $se
           $this->mailManager->mail('contact', 'page_autoreply', $sender_cloned->getEmail(), $current_langcode, $params);
    

    What if this fails? Do we care?

  2. +++ b/core/modules/contact/src/MessageForm.php
    @@ -212,10 +212,24 @@ public function validate(array $form, FormStateInterface $form_state) {
    +        drupal_set_message($this->t('Your message copy has not been sent.'), 'error');
    

    Should this be 'Your message copy could not be sent, please contact the administrator if the problem persists.' or similar - for consistency with the standard error message set by MailManager? Can you add a screenshot of this message and tag the issue as 'Needs usability review' so the UX team can sign off - thanks.

  3. +++ b/core/modules/contact/src/Tests/NotExistEmailContactTest.php
    @@ -0,0 +1,127 @@
    +/**
    + * Reproduces Contact Form Bug https://www.drupal.org/node/2348119
    

    We don't reference issues in comments (except for todos). Please describe the test instead

  4. +++ b/core/modules/contact/src/Tests/NotExistEmailContactTest.php
    @@ -0,0 +1,127 @@
    +  protected $strictConfigSchema = TRUE;
    

    why did we add this, its the default?

  5. +++ b/core/modules/contact/src/Tests/NotExistEmailContactTest.php
    @@ -0,0 +1,127 @@
    +    // Create a valid form.
    

    Comment doesn't seem relevant to next line of code?

  6. +++ b/core/modules/contact/src/Tests/NotExistEmailContactTest.php
    @@ -0,0 +1,127 @@
    +    $this->addContactForm($id = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), "mailnoexist@done1ec.com", '', TRUE);
    

    I think we use drupal.org or example.com for test mail domains

  7. +++ b/core/modules/contact/src/Tests/NotExistEmailContactTest.php
    @@ -0,0 +1,127 @@
    +    $this->assertNoText(t('Your message has been sent.'), 'Did not display "Message sent"');
    

    We aren't testing the case where the copy isn't sent.

  8. +++ b/core/modules/contact/src/Tests/NotExistEmailContactTest.php
    @@ -0,0 +1,127 @@
    +  function addContactForm($id, $label, $recipients, $reply, $selected, $third_party_settings = []) {
    ...
    +  function submitContact($name, $mail, $subject, $id, $message) {
    

    This looks copied from another test, can we add a new trait instead

larowlan’s picture

BTW, great work on this - looking awesome - thanks

googletorp’s picture

1. We are only catching if PHP can send mail, so both should be the same. To really make a better behavior, we would need to have complete control over the error message when messaging fails, which there is a separate issue for. So I vote for leaving it as it is for now.

7. I don't think we need a test for that. One test for handling message could not be sent, should be enough.

googletorp’s picture

Status: Needs work » Needs review
FileSize
6.46 KB
6.65 KB

So I addressed the issues form #57 except #1 + #7.

So what I did was

• Improve actual code a bit, to not display error message if copy message fails. Also less if nesting.
• Simplify the test case removing cruft.
• Don't use methods for creating a contact form and sending a mail since we only do it once.
• New array syntax.

So all should be good.

RavindraSingh’s picture

Updated code looks good. Moving this to RTBC after getting the right output as mentioned in #50

So not uploading the screens again and again.

RavindraSingh’s picture

Status: Needs review » Reviewed & tested by the community
larowlan’s picture

+1 RTBC
Thanks again for your work @RavindraSingh and @googletorp

If you're interested, perhaps we could get a followup to create a ContactTestTrait with convenience methods for adding contact forms and sending messages?

RavindraSingh’s picture

I am not sure about

"create a ContactTestTrait with convenience methods for adding contact forms and sending messages?"

But if you guide us, perhaps we can do that.

xjm’s picture

Status: Reviewed & tested by the community » Needs work

Excellent work. Thanks for uploading a test-only patch above, and for the clear screenshots illustrating the bug.

  1. +++ b/core/modules/contact/src/MailHandler.php
    @@ -144,6 +154,8 @@ public function sendMailMessages(MessageInterface $message, AccountInterface $se
    +    return $message_results;
    

    If we're adding a return value, we probably need to add docs for it?
     

  2. +++ b/core/modules/contact/src/MessageForm.php
    @@ -212,10 +212,19 @@ public function validate(array $form, FormStateInterface $form_state) {
    +    // \Drupal\Core\Mail\MailManager will display an error message, if the
    

    Super minor nit: There is an exta comma before the word "if". (I infer that the comma would be appropriate there in at least German and Dutch based on the contributors who tend to add one, but it's not used there in English.) :)
     

  3. +++ b/core/modules/contact/src/Tests/NotExistEmailContactTest.php
    @@ -0,0 +1,76 @@
    +use Drupal\Component\Utility\Unicode;
    +use Drupal\contact\Entity\ContactForm;
    +use Drupal\Core\Mail\MailFormatHelper;
    +use Drupal\field_ui\Tests\FieldUiTestTrait;
    +use Drupal\simpletest\WebTestBase;
    +use Drupal\Core\Entity\EntityTypeInterface;
    

    Several of these use statements are unused; let's clean that up.
     

  4. +++ b/core/modules/contact/src/Tests/NotExistEmailContactTest.php
    @@ -0,0 +1,76 @@
    +class NotExistEmailContactTest extends WebTestBase {
    

    Minor: The class name is kind of awkward. Maybe NonexistentEmailContactTest?
     

  5. +++ b/core/modules/contact/src/Tests/NotExistEmailContactTest.php
    @@ -0,0 +1,76 @@
    +   * Tests messages displayed when can't send contact mail.
    

    Nit: This is not quite grammatical. I'd suggest: "...when a contact e-mail cannot be sent."
     

  6. +++ b/core/modules/contact/src/Tests/NotExistEmailContactTest.php
    @@ -0,0 +1,76 @@
    +    $this->assertText(t('Unable to send email. Contact the site administrator if the problem persists.'), 'Displayed "Unable to send email..."');
    +    $this->assertNoText(t('Your message has been sent.'), 'Did not display "Message sent"');
    

    So, the second assertion is fragile (well assertNoText() in general is). If the text of the message is later changed elsewhere (and after all the summary shows two variants), then the assertion will pass even if there is a regression.

    I'd suggest writing assertions to make sure the first message is the only message displayed. (And then uploading an additional test-only patch to expose the new failures when posting it.)

    Also, minor, but we can remove the optional assertion message text arguments from these as it's redundant. Usually assertText() and assertNoText() have sufficient information in their default messages. (Unlike things like assertEqual() or assertTrue() which give you no clue.)
     

googletorp’s picture

I made a special interdiff for the changes for the test class (since it was renamed, the normal interdiff isn't that useful).

The -TEST patch, is the patch with the test alone.

googletorp’s picture

I should note that I fixed all the comments from @xjm. I changed the test to detect a status message with xpath and ignore the actual content of the message, which should make the test more robust.

The last submitted patch, 66: wrong_message_displayed-2348119-66-TEST.patch, failed testing.

RavindraSingh’s picture

Assigned: Unassigned » RavindraSingh
RavindraSingh’s picture

Assigned: RavindraSingh » Unassigned
Status: Needs review » Needs work

Passed from test patch added in #66 Could you please remove

diff --git a/sites/default/default.services.yml b/sites/default/default.services.yml
old mode 100644
new mode 100755
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
old mode 100644
new mode 100755

Code throwing error:

warning: unable to unlink sites/default/default.services.yml: Permission denied
warning: unable to unlink sites/default/default.settings.php: Permission denied
fatal: unable to write file 'sites/default/default.services.yml' mode 100755: Permission denied
googletorp’s picture

Status: Needs work » Needs review
FileSize
7.11 KB
RavindraSingh’s picture

Awesome, @googletorp great work. moving this to RTBC

RavindraSingh’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 71: wrong_message_displayed-2348119-71.patch, failed testing.

Status: Needs work » Needs review
googletorp’s picture

Status: Needs review » Reviewed & tested by the community

looks like test bot failed one of the daily runs, all should still be good.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/contact/src/MessageForm.php
@@ -212,10 +212,19 @@ public function validate(array $form, FormStateInterface $form_state) {
+    // \Drupal\Core\Mail\MailManager will display an error message if the
+    // message couldn't be sent, so only set a message if it was sent.
+    if (!empty($message_results[MailHandler::MESSAGE_RECIPIENT]['result'])) {
+      drupal_set_message($this->t('Your message has been sent.'));
+    }
+
+    if (!empty($message_results[MailHandler::MESSAGE_COPY]['result'])) {
+      drupal_set_message($this->t('Your message copy has been sent.'));
+    }

It's a bit odd to have two messages as a result of one action. What happens if the second one fails but the first is successful. You'll get message saying "Your message has been sent" - most people would assume that means the copy too.

Maybe I have these reservations because the texts are so similar - the second text could be "A copy has been sent to the sender". But all of this language is really odd... since on the form the label is "Send copy to sender" which really means send a copy to yourself. Apart from the time when you use someone else's email address... so it's not your address... so is it your message?!?! Who knows?

Setting back to needs review to get more feedback.

googletorp’s picture

Issue tags: -Novice

Hmm.

Part of out problems here is out of scope for this. Right now when a message failed to be sent, we get a standard message error message. Ideally we would like something like this to be possible:

  • Failed to send the message
  • The copy message has been sent to the sender

and

  • Your message has been sent
  • Failed to send the copy message to the sender

But we can't really do that right now, so your first case about the copy message failing is hopeless bad right now, since we would first display the generic failed to send email, followed by the "your message has been sent" message, both being correct. We can't really improve this until #2349725: Core Mail class prints non-overridable errors on the page has been resolved.

I'll leave it to the native English speaking people to improve the message about the copy in it needs improving, but I'm in favor of committing this as is instead of wasting more time bike-shedding. Texts can be improved later on if needed.

googletorp’s picture

Status: Needs review » Reviewed & tested by the community

So for now, this is a good as we can get, until #2349725: Core Mail class prints non-overridable errors on the page lands, putting back to RTBC unless Alex Pott disagrees with this.

alexpott’s picture

Status: Reviewed & tested by the community » Postponed

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

casey’s picture

FileSize
4.17 KB

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

casey’s picture

FileSize
4.15 KB

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
quietone’s picture

Status: Postponed » Active

I have not triaged this issue but it is no longer postponed.

Is this still a problem?

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

brad.bulger’s picture

Yes, at least in the sense that the Contact module is not checking if the result of sending the mail is successful or not in sendMailMessages() - it just assumes it worked.

This came up for me because I am using hook_mail_alter() to prevent sending mail to the addresses of blocked users.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.