Skip to content

Commit

Permalink
FEATURE: Add a mail command (not only) for testing
Browse files Browse the repository at this point in the history
This adds the command mail:send to send a mail
through swiftmailer.
  • Loading branch information
daniellienert committed Jul 7, 2020
1 parent 91162e2 commit 9f2ba7d
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Classes/Command/EmailCommandController.php
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));
}
}

0 comments on commit 9f2ba7d

Please sign in to comment.