Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sending email on Tugboat and Lando #6100

Closed
1 of 4 tasks
ndouglas opened this issue Aug 12, 2021 · 5 comments
Closed
1 of 4 tasks

Fix sending email on Tugboat and Lando #6100

ndouglas opened this issue Aug 12, 2021 · 5 comments

Comments

@ndouglas
Copy link
Contributor

Description

See this Slack thread.

As a developer, it'd be nifty if I could send email so I could verify that mail can be sent.

Email does not appear to be working on Tugboat or Lando, but does work on BRD.

Email can be sent (and is captured appropriately) from the command line through PHP:

drush eval 'mail("nathan.douglas@agile6.com", "drush eval", "");'

and from calling Drupal services directly:

drush eval '\Drupal::service("plugin.manager.mail")->mail("nug_doug", "nug_doug_key", "nathan.douglas@agile6.com", "en", ["message" => "", "title" => "service"], NULL, TRUE);'

But there seems to be a breakdown at some point that prevents email from being sent for e.g. password-reset requests. This should be identified and solved.

Acceptance Criteria

  • Email can be sent (and is captured by Mailhog) when we attempt to send email through Drupal from Lando.
  • Email can be sent (and is captured by Tugboat) when we attempt to send email through Drupal from Tugboat environments.

CMS Team

  • Core Application Team
  • Product Support Team
@ndouglas
Copy link
Contributor Author

hmm

Screen Shot 2021-08-12 at 11 20 12 AM

@ndouglas
Copy link
Contributor Author

ndouglas commented Aug 12, 2021

whee, so:

From _user_mail_notify() in user.module:

Screen Shot 2021-08-12 at 1 13 39 PM

That's gonna fail if the user doesn't have an email address associated with their account. As mine doesn't.

I injected the following code in Drupal\Core\Mail\Plugin\Mail\PhpMail::mail(), right before \mail()` is called:

      \Drupal::logger('lol')->error(json_encode([
        'to' => $message['to'],
        'subject' => $mail_subject,
        'body' => $mail_body,
        'headers' => $mail_headers,
        'additional_headers' => $additional_headers,
      ], JSON_PRETTY_PRINT));

Before setting an email address on my account:
Screen Shot 2021-08-12 at 1 06 40 PM

After setting an email address on my account:
Screen Shot 2021-08-12 at 1 07 27 PM

I'd recommend that we write a script to update all users to set their email address equal to their account name, if it's not already set and the account name is a valid email address, and check to make sure we always set the email address specifically.

EDIT: It looks as though this might be triggered by the sanitization process performed on the DB as part of the sync to lower environments.

EDIT 2: Or this step where we do it explicitly.
Screen Shot 2021-08-12 at 1 28 35 PM

TL;DR: If you want to test email on a lower environment, it should work once you set the account email explicitly. Also, don't expect Drupal or PHP to throw any errors because of the lack of a 'To' address. They won't.

@ndouglas
Copy link
Contributor Author

Gonna close this as invalid; @acrollet @ElijahLynn thoughts on where I might document this? I was thinking about adding a README for gotchas/troubleshooting the local/tugboat dev process.

@ndouglas ndouglas self-assigned this Aug 12, 2021
@ndouglas ndouglas added this to the CMS Sprint 38 - Core milestone Aug 12, 2021
@acrollet
Copy link
Contributor

Gonna close this as invalid; @acrollet @ElijahLynn thoughts on where I might document this? I was thinking about adding a README for gotchas/troubleshooting the local/tugboat dev process.

@ndouglas what if we add a line on the existing local and tugboat readmes? IMO we already have so many READMEs that it's hard to know what's where...

@ndouglas
Copy link
Contributor Author

Yeah, I think you're right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants