generateBody() public method

Returns an empty string if no body has been set.
public generateBody ( ) : string
return string
コード例 #1
0
 function sendMail(ezcMail $mail)
 {
     $separator = "/";
     $mail->appendExcludeHeaders(array('to', 'subject'));
     $headers = rtrim($mail->generateHeaders());
     // rtrim removes the linebreak at the end, mail doesn't want it.
     if (count($mail->to) + count($mail->cc) + count($mail->bcc) < 1) {
         throw new ezcMailTransportException('No recipient addresses found in message header.');
     }
     $additionalParameters = "";
     if (isset($mail->returnPath)) {
         $additionalParameters = "-f{$mail->returnPath->email}";
     }
     $sys = eZSys::instance();
     $fname = time() . '-' . rand() . '.mail';
     $qdir = eZSys::siteDir() . eZSys::varDirectory() . $separator . 'mailq';
     $data = $headers . ezcMailTools::lineBreak();
     $data .= ezcMailTools::lineBreak();
     $data .= $mail->generateBody();
     $data = preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $data);
     $success = eZFile::create($fname, $qdir, $data);
     if ($success === false) {
         throw new ezcMailTransportException('The email could not be sent by sendmail');
     }
 }
コード例 #2
0
 /**
  * Sends the mail $mail using the PHP mail method.
  *
  * Note that a message may not arrive at the destination even though
  * it was accepted for delivery.
  *
  * @throws ezcMailTransportException
  *         if the mail was not accepted for delivery by the MTA.
  * @param ezcMail $mail
  */
 public function send(ezcMail $mail)
 {
     $mail->appendExcludeHeaders(array('to', 'subject'));
     $headers = rtrim($mail->generateHeaders());
     // rtrim removes the linebreak at the end, mail doesn't want it.
     if (count($mail->to) + count($mail->cc) + count($mail->bcc) < 1) {
         throw new ezcMailTransportException('No recipient addresses found in message header.');
     }
     $additionalParameters = "";
     if (isset($mail->returnPath)) {
         $additionalParameters = "-f{$mail->returnPath->email}";
     }
     $success = mail(ezcMailTools::composeEmailAddresses($mail->to), $mail->getHeader('Subject'), $mail->generateBody(), $headers, $additionalParameters);
     if ($success === false) {
         throw new ezcMailTransportException('The email could not be sent by sendmail');
     }
 }
コード例 #3
0
ファイル: mail_test.php プロジェクト: jacomyma/GEXF-Atlas
 public function testIsSet()
 {
     $mail = new ezcMail();
     $mail->generateBody();
     $mail->generateHeaders();
     $this->assertEquals(true, isset($mail->headers));
     $this->assertEquals(false, isset($mail->contentDisposition));
     $this->assertEquals(true, isset($mail->to));
     $this->assertEquals(true, isset($mail->cc));
     $this->assertEquals(true, isset($mail->bcc));
     $this->assertEquals(false, isset($mail->from));
     $this->assertEquals(false, isset($mail->subject));
     $this->assertEquals(true, isset($mail->subjectCharset));
     $this->assertEquals(false, isset($mail->body));
     $this->assertEquals(false, isset($mail->messageId));
     $this->assertEquals(false, isset($mail->messageID));
     $this->assertEquals(true, isset($mail->timestamp));
     $this->assertEquals(false, isset($mail->no_such_property));
 }