/** * E-mails the formatted text as attachment. * * @param string $formatedText */ public function write($formatedText) { $mail = new Mail(); $mail->addTo($this->to); $mail->setFrom($this->from); $mail->setSubject($this->subject); $mail->setBodyHtml(file_get_contents($this->emailTemplate)); $at = new Part($formatedText); $at->type = 'text/html'; $at->disposition = Mime::DISPOSITION_INLINE; $at->encoding = Mime::ENCODING_BASE64; $at->filename = $this->attachmentName; $at->description = 'LiveTest Attachment'; $mail->addAttachment($at); $mail->send(); }
private function writeMail($bodyText, $atText = null) { $mail = new Mail(); $mail->addTo($this->to); $mail->setFrom($this->from); $mail->setSubject($this->subject); $mail->setBodyHtml(file_get_contents($this->template) . $bodyText); if ($at !== null) { $at = new Part($atText); $at->type = 'text/html'; $at->disposition = Mime::DISPOSITION_INLINE; $at->encoding = Mime::ENCODING_BASE64; $at->filename = $this->attachmentName; $at->description = 'LiveTest Attachment'; $mail->addAttachment($at); } $mail->send(); }
/** * @group ZF-9011 * */ public function testSendmailTransportThrowsExceptionWithInvalidParams() { $mail = new Mail\Mail("UTF-8"); $mail->setBodyText('My Nice Test Text'); $mail->addTo('*****@*****.**'); $mail->setSubject('hello world!'); $transport = new Transport\Sendmail(); $transport->parameters = true; try { $mail->send($transport); $this->fail('Exception should have been thrown, but wasn\'t'); } catch(Transport\Exception $e) { // do nothing } }
protected function _prepareMail() { $mail = new Mail\Mail(); $mail->setBodyText('This is the text of the mail.'); $mail->setFrom('*****@*****.**', 'Alexander Steshenko'); $mail->addTo('*****@*****.**', 'Oleg Lobach'); $mail->setSubject('TestSubject'); return $mail; }