send($message); $lastEmail = $this->getLastEmail(); $this->assertResponse($response); $this->assertEquals($to, $lastEmail['to'][0]['address']); $this->assertEquals($fromEmail, $lastEmail['from'][0]['address']); $this->assertEquals($subject, $lastEmail['subject']); $this->assertEquals($content, \trim($lastEmail['text'])); } public function testSendEmailWithAttachment(): void { $sender = new SMTP( host: 'maildev', port: 1025, ); $to = 'tester@localhost.test'; $subject = 'Test Subject'; $content = 'Test Content'; $fromName = 'Test Sender'; $fromEmail = 'sender@localhost.test'; $message = new Email( to: [$to], subject: $subject, content: $content, fromName: $fromName, fromEmail: $fromEmail, attachments: [new Attachment( name: 'image.png', path: __DIR__ . '/../../../assets/image.png', type: 'image/png' )], ); $response = $sender->send($message); $lastEmail = $this->getLastEmail(); $this->assertResponse($response); $this->assertEquals($to, $lastEmail['to'][0]['address']); $this->assertEquals($fromEmail, $lastEmail['from'][0]['address']); $this->assertEquals($subject, $lastEmail['subject']); $this->assertEquals($content, \trim($lastEmail['text'])); } }