Esempio n. 1
0
    public function testSendHtmlAndAttachment()
    {
        $token = $this->generateSubjectToken();
        $email = new fEmail();
        $email->setFromEmail('*****@*****.**');
        $email->addRecipient(EMAIL_ADDRESS, 'Test User');
        $email->setSubject($token . ': Testing Attachment/HTML');
        $email->setBody('This is a test of sending an attachment with an HTML body');
        $email->setHTMLBody('<h1>Attachment/HTML Body Test</h1>
<p>
	This is a test of sending both an HTML alternative, while also sending an attachment.
</p>');
        $bar_gif_contents = file_get_contents('./resources/images/bar.gif');
        $email->addAttachment('bar.gif', 'image/gif', $bar_gif_contents);
        $message_id = $email->send();
        $message = $this->findMessage($token);
        $this->assertEquals($message_id, $message['headers']['Message-ID']);
        $this->assertEquals('*****@*****.**', $message['headers']['From']);
        $this->assertEquals($token . ': Testing Attachment/HTML', $message['headers']['Subject']);
        $this->assertEquals('This is a test of sending an attachment with an HTML body', $message['plain']);
        $this->assertEquals('<h1>Attachment/HTML Body Test</h1>
<p>
	This is a test of sending both an HTML alternative, while also sending an attachment.
</p>', $message['html']);
        $this->assertEquals(array(array('filename' => 'bar.gif', 'mimetype' => 'image/gif', 'contents' => $bar_gif_contents)), $message['attachments'], 'The attachment did not match the original file contents');
    }