/** * @param EmailOptions $options * @return EmailInterface */ public function createEmail(EmailOptions $options) { $transport = Factory::create($options->getTransport()); $email = new Email($transport); $from = $options->getFrom(); if (is_array($from)) { $from = new Address($from[0], $from[1]); } $email->setFrom($from); return $email; }
public function testBasicUsage() { $mailTransport = $this->getMockBuilder(TransportInterface::class)->getMock(); $attachment = $this->getMockBuilder(AttachmentInterface::class)->getMock(); $email = new Email($mailTransport); $email->setBody('test'); $email->setIsHTML(true); $email->addAttachment($attachment); $this->assertCount(1, $email->getAttachments()); $this->assertEquals($attachment, $email->getAttachments()[0]); $this->assertTrue($email->send()); }