-
-
Notifications
You must be signed in to change notification settings - Fork 836
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add UI, backend for sending test emails - Change mail settings endpoint to /api/mail/settings
- Loading branch information
1 parent
63242ed
commit d1750fe
Showing
4 changed files
with
112 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Flarum. | ||
* | ||
* For detailed copyright and license information, please view the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Flarum\Api\Controller; | ||
|
||
use Flarum\User\AssertPermissionTrait; | ||
use Illuminate\Container\Container; | ||
use Illuminate\Contracts\Mail\Mailer; | ||
use Illuminate\Mail\Message; | ||
use Laminas\Diactoros\Response\EmptyResponse; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
use Symfony\Component\Translation\TranslatorInterface; | ||
|
||
class SendTestMailController implements RequestHandlerInterface | ||
{ | ||
use AssertPermissionTrait; | ||
|
||
protected $container; | ||
|
||
protected $mailer; | ||
|
||
protected $translator; | ||
|
||
public function __construct(Container $container, Mailer $mailer, TranslatorInterface $translator) | ||
{ | ||
$this->container = $container; | ||
$this->mailer = $mailer; | ||
$this->translator = $translator; | ||
} | ||
|
||
public function handle(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
$actor = $request->getAttribute('actor'); | ||
$this->assertAdmin($actor); | ||
|
||
$body = $this->translator->trans('core.email.send_test.body', ['{username}' => $actor->username]); | ||
|
||
$this->mailer->raw($body, function (Message $message) use ($actor) { | ||
$message->to($actor->email); | ||
$message->subject($this->translator->trans('core.email.send_test.subject')); | ||
}); | ||
|
||
return new EmptyResponse(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters