function PHPMailer::WrapText in SMTP Authentication Support 5
Same name and namespace in other branches
- 7.2 smtp.phpmailer.inc \PHPMailer::WrapText()
- 7 smtp.phpmailer.inc \PHPMailer::WrapText()
Wraps message for use with mailers that do not automatically perform wrapping and for quoted-printable. Original written by philippe. @access private
Return value
string
3 calls to PHPMailer::WrapText()
- PHPMailer::EncodeHeader in ./
smtp.module - Encode a header string to best of Q, B, quoted or none. @access private
- PHPMailer::EncodeQP in ./
smtp.module - Encode string to quoted-printable. @access private
- PHPMailer::SetWordWrap in ./
smtp.module - Set the body wrapping. @access private
File
- ./
smtp.module, line 1120 - Enables drupal to send email directly to an SMTP server using authentication. Uses the PHPMailer class by Brent R. Matzelle.
Class
- PHPMailer
- PHPMailer - PHP email transport class @package PHPMailer @author Brent R. Matzelle @copyright 2001 - 2003 Brent R. Matzelle
Code
function WrapText($message, $length, $qp_mode = false) {
$soft_break = $qp_mode ? sprintf(" =%s", $this->LE) : $this->LE;
$message = $this
->FixEOL($message);
if (substr($message, -1) == $this->LE) {
$message = substr($message, 0, -1);
}
$line = explode($this->LE, $message);
$message = "";
for ($i = 0; $i < count($line); $i++) {
$line_part = explode(" ", $line[$i]);
$buf = "";
for ($e = 0; $e < count($line_part); $e++) {
$word = $line_part[$e];
if ($qp_mode and strlen($word) > $length) {
$space_left = $length - strlen($buf) - 1;
if ($e != 0) {
if ($space_left > 20) {
$len = $space_left;
if (substr($word, $len - 1, 1) == "=") {
$len--;
}
elseif (substr($word, $len - 2, 1) == "=") {
$len -= 2;
}
$part = substr($word, 0, $len);
$word = substr($word, $len);
$buf .= " " . $part;
$message .= $buf . sprintf("=%s", $this->LE);
}
else {
$message .= $buf . $soft_break;
}
$buf = "";
}
while (strlen($word) > 0) {
$len = $length;
if (substr($word, $len - 1, 1) == "=") {
$len--;
}
elseif (substr($word, $len - 2, 1) == "=") {
$len -= 2;
}
$part = substr($word, 0, $len);
$word = substr($word, $len);
if (strlen($word) > 0) {
$message .= $part . sprintf("=%s", $this->LE);
}
else {
$buf = $part;
}
}
}
else {
$buf_o = $buf;
$buf .= $e == 0 ? $word : " " . $word;
if (strlen($buf) > $length and $buf_o != "") {
$message .= $buf_o . $soft_break;
$buf = $word;
}
}
}
$message .= $buf . $this->LE;
}
return $message;
}