getMessage() public method

Get the message.
public getMessage ( ) : string
return string
示例#1
0
 /**
  * Save mail message or messages in a folder to be sent at a later date.
  *
  * @param string $to
  * @param string $format
  * @return \Pop\Mail\Mail
  */
 public function saveTo($to = null, $format = null)
 {
     $dir = null !== $to ? $to : getcwd();
     if (null === $this->message->getMessage()) {
         $this->message->init();
     }
     $messageBody = $this->message->getMessage();
     $headers = $this->buildHeaders();
     // Send as group message
     if ($this->group) {
         $email = 'To: ' . (string) $this->queue . $this->message->getEol() . 'Subject: ' . $this->subject . $this->message->getEol() . $headers . $this->message->getEol() . $this->message->getEol() . $messageBody;
         $emailFileName = null !== $format ? $format : ($emailFileName = '0000000001-' . time() . '-popphpmail');
         // Save the email message.
         file_put_contents($dir . DIRECTORY_SEPARATOR . $emailFileName, array(), $email);
     } else {
         // Iterate through the queue and send the mail messages.
         $i = 1;
         foreach ($this->queue as $rcpt) {
             $fileFormat = null;
             $subject = $this->subject;
             $message = $messageBody;
             // Set the recipient parameter.
             $to = isset($rcpt['name']) ? $rcpt['name'] . " <" . $rcpt['email'] . ">" : $rcpt['email'];
             // Replace any set placeholder content within the subject or message.
             foreach ($rcpt as $key => $value) {
                 $subject = str_replace('[{' . $key . '}]', $value, $subject);
                 $message = str_replace('[{' . $key . '}]', $value, $message);
                 if (null !== $format) {
                     if (null !== $fileFormat) {
                         $fileFormat = str_replace('[{' . $key . '}]', $value, $fileFormat);
                     } else {
                         $fileFormat = str_replace('[{' . $key . '}]', $value, $format);
                     }
                 }
             }
             $email = 'To: ' . $to . $this->message->getEol() . 'Subject: ' . $subject . $this->message->getEol() . $headers . $this->message->getEol() . $this->message->getEol() . $message;
             if (null !== $fileFormat) {
                 $emailFileName = sprintf('%09d', $i) . '-' . time() . '-' . $fileFormat;
             } else {
                 $emailFileName = sprintf('%09d', $i) . '-' . time() . '-popphpmail';
             }
             // Save the email message.
             file_put_contents($dir . DIRECTORY_SEPARATOR . $emailFileName, $email);
             $i++;
         }
     }
     return $this;
 }