Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Hevelop\Example\Console\Command;
- use Symfony\Component\Console\Command\Command;
- use Magento\Framework\Mail\TransportInterfaceFactory;
- /**
- * Class SendMailWithoutTemplate
- */
- class SendMailWithoutTemplate extends Command
- {
- /**
- * @var TransportInterfaceFactory
- */
- protected $mailTransportFactory;
- /**
- * @param ResourceConnection $dbConnection
- * @throws \LogicException
- */
- public function __construct(
- TransportInterfaceFactory $mailTransportFactory
- )
- {
- $this->mailTransportFactory = $mailTransportFactory;
- parent::__construct();
- }
- /**
- * Configures the current command.
- * @throws \InvalidArgumentException
- */
- protected function configure()
- {
- $this->setName('example:sendmail')
- ->setDescription('Send a simple mail');
- parent::configure();
- }
- public function execute()
- {
- $message = new \Magento\Framework\Mail\Message();
- $message->setFrom('mail.recipient@example.com');
- $message->addTo('mail.tosent@example.com');
- $message->setSubject('Subject');
- $message->setBody('Body');
- $transport = $this->mailTransportFactory->create(['message' => $message]);
- $transport->sendMessage();
- }
- }
Add Comment
Please, Sign In to add comment