| 683 | | $body = wordwrap(trim($body), 80); |
| | 683 | { |
| | 684 | // Rebuild the message body with a maximum of 80 chars, while keeping |
| | 685 | // quoted message. |
| | 686 | $lines = preg_split('/\r?\n/', trim($body)); |
| | 687 | $body = ''; |
| | 688 | |
| | 689 | foreach ($lines as $line) |
| | 690 | { |
| | 691 | if (strlen($line) > 80) |
| | 692 | { |
| | 693 | if (preg_match('/^(>+\s*)+/', $line, $regs)) |
| | 694 | { |
| | 695 | $length = strlen($regs[0]); |
| | 696 | $prefix = substr($line, 0, $length); |
| | 697 | |
| | 698 | // Remove '> ' from the line, then wordwrap() the line |
| | 699 | $line = substr($line, $length); |
| | 700 | $line = wordwrap($line, 80 - $length); |
| | 701 | |
| | 702 | // Rebuild the line with '> ' at the beginning of each 'subline' |
| | 703 | $newline = ''; |
| | 704 | $line = explode("\n", $line); |
| | 705 | |
| | 706 | foreach ($line as $l) |
| | 707 | { |
| | 708 | $newline .= $prefix.$l."\n"; |
| | 709 | } |
| | 710 | |
| | 711 | // Remove the righest newline char |
| | 712 | $line = rtrim($newline); |
| | 713 | } |
| | 714 | else |
| | 715 | { |
| | 716 | $line = wordwrap($line, 80); |
| | 717 | } |
| | 718 | } |
| | 719 | |
| | 720 | // Append the line |
| | 721 | $body .= $line."\n"; |
| | 722 | } |
| | 723 | } |