Mail.php 933 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. trait Mail {
  7. // CommandLine trait is expected to be used in the class that uses this
  8. // trait.
  9. /**
  10. * @var string
  11. */
  12. private $fakeSmtpServerPid;
  13. /**
  14. * @AfterScenario
  15. */
  16. public function killDummyMailServer() {
  17. if (!$this->fakeSmtpServerPid) {
  18. return;
  19. }
  20. exec('kill ' . $this->fakeSmtpServerPid);
  21. $this->invokingTheCommand('config:system:delete mail_smtpport');
  22. }
  23. /**
  24. * @Given /^dummy mail server is listening$/
  25. */
  26. public function dummyMailServerIsListening() {
  27. // Default smtpport (25) is restricted for regular users, so the
  28. // FakeSMTP uses 2525 instead.
  29. $this->invokingTheCommand('config:system:set mail_smtpport --value=2525 --type integer');
  30. $this->fakeSmtpServerPid = exec('php features/bootstrap/FakeSMTPHelper.php >/dev/null 2>&1 & echo $!');
  31. }
  32. }