public function testSendNestedMultipartMail() { $headers = "From: foo@foo.com\r\n" . "Content-Type: multipart/mixed; boundary=\"boundary-1\"\r\n"; $message = "--boundary-1\r\n" . "Content-Type: multipart/alternative; boundary=\"boundary-2\"\r\n" . "\r\n" . "--boundary-2\r\n" . "Content-Type: text/plain\r\n" . "\r\n" . "body in text\r\n" . "--boundary-2\r\n" . "Content-Type: text/html\r\n" . "\r\n" . "<div>body in html</div>\r\n" . "--boundary-2--\r\n" . "--boundary-1\r\n" . "Content-Type: text/plain\r\n" . "Content-Disposition: attachment; filename=\"test.txt\"\r\n" . "\r\n" . "attachment in plain text\r\n"; "--boundary-1--\r\n"; $message_proto = new MailMessage(); $message_proto->setSender('*****@*****.**'); $message_proto->addTo('*****@*****.**'); $message_proto->setSubject('subject'); $message_proto->setTextBody('body in text'); $message_proto->setHtmlBody('<div>body in html</div>'); $attachment1 = $message_proto->addAttachment(); $attachment1->setFilename('test.txt'); $attachment1->setData('attachment in plain text'); $response = new VoidProto(); $this->apiProxyMock->expectCall('mail', 'Send', $message_proto, $response); $ret = Mail::sendMail('*****@*****.**', 'subject', $message, $headers); $this->assertTrue($ret); $this->apiProxyMock->verify(); }