| | |
| | | * @param string $message Message content |
| | | * @param array $flags Message flags |
| | | * @param string $date Message internal date |
| | | * @param bool $binary Enable BINARY append (RFC3516) |
| | | * |
| | | * @return string|bool On success APPENDUID response (if available) or True, False on failure |
| | | */ |
| | | function append($mailbox, &$message, $flags = array(), $date = null) |
| | | function append($mailbox, &$message, $flags = array(), $date = null, $binary = false) |
| | | { |
| | | unset($this->data['APPENDUID']); |
| | | |
| | |
| | | return false; |
| | | } |
| | | |
| | | $binary = $binary && $this->getCapability('BINARY'); |
| | | $literal_plus = !$binary && $this->prefs['literal+']; |
| | | |
| | | if (!$binary) { |
| | | $message = str_replace("\r", '', $message); |
| | | $message = str_replace("\n", "\r\n", $message); |
| | | } |
| | | |
| | | $len = strlen($message); |
| | | if (!$len) { |
| | |
| | | if (!empty($date)) { |
| | | $request .= ' ' . $this->escape($date); |
| | | } |
| | | $request .= ' {' . $len . ($this->prefs['literal+'] ? '+' : '') . '}'; |
| | | $request .= ' ' . ($binary ? '~' : '') . '{' . $len . ($literal_plus ? '+' : '') . '}'; |
| | | |
| | | // send APPEND command |
| | | if ($this->putLine($request)) { |
| | | // Do not wait when LITERAL+ is supported |
| | | if (!$this->prefs['literal+']) { |
| | | if (!$literal_plus) { |
| | | $line = $this->readReply(); |
| | | |
| | | if ($line[0] != '+') { |
| | |
| | | * @param string $headers Message headers |
| | | * @param array $flags Message flags |
| | | * @param string $date Message internal date |
| | | * @param bool $binary Enable BINARY append (RFC3516) |
| | | * |
| | | * @return string|bool On success APPENDUID response (if available) or True, False on failure |
| | | */ |
| | | function appendFromFile($mailbox, $path, $headers=null, $flags = array(), $date = null) |
| | | function appendFromFile($mailbox, $path, $headers=null, $flags = array(), $date = null, $binary = false) |
| | | { |
| | | unset($this->data['APPENDUID']); |
| | | |
| | |
| | | $len += strlen($headers) + strlen($body_separator); |
| | | } |
| | | |
| | | $binary = $binary && $this->getCapability('BINARY'); |
| | | $literal_plus = !$binary && $this->prefs['literal+']; |
| | | |
| | | // build APPEND command |
| | | $key = $this->nextTag(); |
| | | $request = "$key APPEND " . $this->escape($mailbox) . ' (' . $this->flagsToStr($flags) . ')'; |
| | | if (!empty($date)) { |
| | | $request .= ' ' . $this->escape($date); |
| | | } |
| | | $request .= ' {' . $len . ($this->prefs['literal+'] ? '+' : '') . '}'; |
| | | $request .= ' ' . ($binary ? '~' : '') . '{' . $len . ($literal_plus ? '+' : '') . '}'; |
| | | |
| | | // send APPEND command |
| | | if ($this->putLine($request)) { |
| | | // Don't wait when LITERAL+ is supported |
| | | if (!$this->prefs['literal+']) { |
| | | if (!$literal_plus) { |
| | | $line = $this->readReply(); |
| | | |
| | | if ($line[0] != '+') { |