-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: Add a mail command (not only) for testing
This adds the command mail:send to send a mail through swiftmailer.
- Loading branch information
1 parent
91162e2
commit 9f2ba7d
Showing
1 changed file
with
44 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neos\SwiftMailer\Command; | ||
|
||
/* | ||
* (c) 2020 punkt.de GmbH - Karlsruhe, Germany - http://punkt.de | ||
* All rights reserved. | ||
*/ | ||
|
||
|
||
use Neos\Flow\Annotations as Flow; | ||
use Neos\Flow\Cli\CommandController; | ||
use Neos\SwiftMailer\Mailer; | ||
use Neos\SwiftMailer\Message; | ||
|
||
class EmailCommandController extends CommandController | ||
{ | ||
|
||
|
||
/** | ||
* A command for creating and sending simple emails. | ||
* | ||
* @param string $from The from address of the message | ||
* @param string $to The to address of the message | ||
* @param string $subject The subject of the message | ||
* @param string $body The body of the message | ||
* @param string $contentType | ||
* @param string $charset | ||
*/ | ||
public function sendCommand(string $from, string $to, string $subject, string $body = '', string $contentType = 'text/plain', $charset = 'UTF8'): void | ||
{ | ||
$message = (new Message()) | ||
->setFrom($from) | ||
->setTo($to) | ||
->setSubject($subject) | ||
->setBody($body) | ||
->setContentType($contentType); | ||
|
||
$sentMessages = $message->send(); | ||
|
||
$this->outputLine(sprintf('<success>%s emails were successfully sent.</success>', $sentMessages)); | ||
} | ||
} |