|
From: <luc...@us...> - 2015-02-16 19:07:52
|
Revision: 12985
http://sourceforge.net/p/xoops/svn/12985
Author: luciorota
Date: 2015-02-16 19:07:35 +0000 (Mon, 16 Feb 2015)
Log Message:
-----------
update PHPMailer
update html2text
fixed bug in text decoding
Modified Paths:
--------------
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/admin/accounts.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/admin/letter.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/admin/template.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/functions.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/functions.task.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/html2text.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/PHPMailerAutoload.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/class.phpmailer.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/class.pop3.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/class.smtp.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/extras/EasyPeasyICS.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/extras/README.md
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/extras/htmlfilter.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/extras/ntlm_sasl_client.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-ar.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-be.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-br.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-ca.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-ch.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-cz.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-de.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-dk.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-el.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-eo.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-es.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-et.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-fa.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-fi.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-fo.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-fr.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-gl.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-he.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-hr.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-hu.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-it.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-ja.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-ka.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-lt.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-lv.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-nl.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-no.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-pl.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-pt.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-ro.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-ru.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-se.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-sk.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-sr.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-tr.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-uk.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-vi.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-zh.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-zh_cn.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/letter.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/xoops_version.php
Added Paths:
-----------
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/README.md
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/src/
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/src/Html2Text.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/src/Html2TextException.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-az.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-id.php
XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/language/phpmailer.lang-ms.php
Modified: XoopsModules/xnewsletter/branches/luciorota/xnewsletter/admin/accounts.php
===================================================================
--- XoopsModules/xnewsletter/branches/luciorota/xnewsletter/admin/accounts.php 2015-02-16 19:00:46 UTC (rev 12984)
+++ XoopsModules/xnewsletter/branches/luciorota/xnewsletter/admin/accounts.php 2015-02-16 19:07:35 UTC (rev 12985)
@@ -200,6 +200,7 @@
imap_close($mbox);
}
echo "</table>";
+ include_once __DIR__ . '/admin_footer.php';
break;
case 'list':
Modified: XoopsModules/xnewsletter/branches/luciorota/xnewsletter/admin/letter.php
===================================================================
--- XoopsModules/xnewsletter/branches/luciorota/xnewsletter/admin/letter.php 2015-02-16 19:00:46 UTC (rev 12984)
+++ XoopsModules/xnewsletter/branches/luciorota/xnewsletter/admin/letter.php 2015-02-16 19:07:35 UTC (rev 12985)
@@ -98,7 +98,7 @@
echo $htmlBody;
echo "</div>";
echo "<div style='padding:10px; margin:0px; border:1px solid black; font-family: monospace;'>";
- echo nl2br(utf8_encode($textBody));
+ echo nl2br(utf8_decode($textBody));
echo "</div>";
echo "</div>";
include_once __DIR__ . '/admin_footer.php';
Modified: XoopsModules/xnewsletter/branches/luciorota/xnewsletter/admin/template.php
===================================================================
--- XoopsModules/xnewsletter/branches/luciorota/xnewsletter/admin/template.php 2015-02-16 19:00:46 UTC (rev 12984)
+++ XoopsModules/xnewsletter/branches/luciorota/xnewsletter/admin/template.php 2015-02-16 19:07:35 UTC (rev 12985)
@@ -87,7 +87,7 @@
echo $htmlBody;
echo "</div>";
echo "<div style='padding:10px;border:1px solid black; font-family: monospace;'>";
- echo nl2br(utf8_encode($textBody));
+ echo nl2br(utf8_decode($textBody));
echo "</div>";
echo "</div>";
include_once __DIR__ . '/admin_footer.php';
Modified: XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/functions.php
===================================================================
--- XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/functions.php 2015-02-16 19:00:46 UTC (rev 12984)
+++ XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/functions.php 2015-02-16 19:07:35 UTC (rev 12985)
@@ -555,7 +555,7 @@
$htmlBody = $letterTpl->fetch($template);
}
$textBody = xnewsletter_html2text($htmlBody); // new from v1.3
- //$textBody = mb_convert_encoding($textBody, 'ISO-8859-1', _CHARSET); // "text/plain; charset=us-ascii" [http://www.w3.org/Protocols/rfc1341/7_1_Text.html]
+ $textBody = mb_convert_encoding($textBody, 'ISO-8859-1', _CHARSET); // "text/plain; charset=us-ascii" [http://www.w3.org/Protocols/rfc1341/7_1_Text.html]
// get letter attachments as attachment
$attachmentAsAttachmentCriteria = new CriteriaCompo();
@@ -591,7 +591,7 @@
$mail->Subject = html_entity_decode($letter_title, ENT_QUOTES);
$mail->AddAddress($letterObj->getVar('letter_email_test'), _AM_XNEWSLETTER_SUBSCR_FIRSTNAME_PREVIEW . " " . _AM_XNEWSLETTER_SUBSCR_LASTNAME_PREVIEW);
- $mail->MsgHTML($htmlBody); // $mail->Body = $htmlBody;
+ $mail->Body = $htmlBody;
$mail->AltBody = $textBody;
foreach ($attachmentsPath as $attachmentPath) {
Modified: XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/functions.task.php
===================================================================
--- XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/functions.task.php 2015-02-16 19:00:46 UTC (rev 12984)
+++ XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/functions.task.php 2015-02-16 19:07:35 UTC (rev 12985)
@@ -373,10 +373,10 @@
$htmlBody = $letterTpl->fetch($template);
}
$textBody = xnewsletter_html2text($htmlBody); // new from v1.3
- //$textBody = mb_convert_encoding($textBody, 'ISO-8859-1', _CHARSET); // "text/plain; charset=us-ascii" [http://www.w3.org/Protocols/rfc1341/7_1_Text.html]
+ $textBody = mb_convert_encoding($textBody, 'ISO-8859-1', _CHARSET); // "text/plain; charset=us-ascii" [http://www.w3.org/Protocols/rfc1341/7_1_Text.html]
$mail->AddAddress($recipient['address'], $recipient['firstname'] . ' ' . $recipient['lastname']);
- $mail->MsgHTML($htmlBody); // $mail->Body = $htmlBody;
+ $mail->Body = $htmlBody;
$mail->AltBody = $textBody;
foreach ($attachmentsPath as $attachmentPath) {
Added: XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/README.md
===================================================================
--- XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/README.md (rev 0)
+++ XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/README.md 2015-02-16 19:07:35 UTC (rev 12985)
@@ -0,0 +1,71 @@
+html2text
+=========
+
+html2text is a very simple script that uses PHP's DOM methods to load from HTML, and then iterates over the resulting DOM to correctly output plain text. For example:
+
+```html
+<html>
+<title>Ignored Title</title>
+<body>
+ <h1>Hello, World!</h1>
+
+ <p>This is some e-mail content.
+ Even though it has whitespace and newlines, the e-mail converter
+ will handle it correctly.
+
+ <p>Even mismatched tags.</p>
+
+ <div>A div</div>
+ <div>Another div</div>
+ <div>A div<div>within a div</div></div>
+
+ <a href="http://foo.com">A link</a>
+
+</body>
+</html>
+```
+
+Will be converted into:
+
+```text
+Hello, World!
+
+This is some e-mail content. Even though it has whitespace and newlines, the e-mail converter will handle it correctly.
+
+Even mismatched tags.
+A div
+Another div
+A div
+within a div
+[A link](http://foo.com)
+```
+
+See the [original blog post](http://journals.jevon.org/users/jevon-phd/entry/19818) or the related [StackOverflow answer](http://stackoverflow.com/a/2564472/39531).
+
+## Installing
+
+You can use [Composer](http://getcomposer.org/) to add the [package](https://packagist.org/packages/soundasleep/html2text) to your project:
+
+```json
+{
+ "require": {
+ "soundasleep/html2text": "~0.2"
+ }
+}
+```
+
+And then use it quite simply:
+
+```php
+$text = Html2Text\Html2Text::convert($html);
+```
+
+You can also include the supplied `html2text.php` and use `$text = convert_html_to_text($html);` instead.
+
+## Tests
+
+Some very basic tests are provided in the `tests/` directory. Run them with `composer install --dev && vendor/bin/phpunit`.
+
+## License
+
+`html2text` is dual licensed under both [EPL v1.0](https://www.eclipse.org/legal/epl-v10.html) and [LGPL v3.0](http://www.gnu.org/licenses/lgpl.html), making it suitable for both Eclipse and GPL projects.
Modified: XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/html2text.php
===================================================================
--- XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/html2text.php 2015-02-16 19:00:46 UTC (rev 12984)
+++ XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/html2text.php 2015-02-16 19:07:35 UTC (rev 12985)
@@ -6,262 +6,27 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * or
+ *
+ * LGPL which is available at http://www.gnu.org/licenses/lgpl.html
+ *
+ *
* Contributors:
* Jevon Wright - initial API and implementation
****************************************************************************/
/**
- * Tries to convert the given HTML into a plain text format - best suited for
- * e-mail display, etc.
- *
- * <p>In particular, it tries to maintain the following features:
- * <ul>
- * <li>Links are maintained, with the 'href' copied over
- * <li>Information in the <head> is lost
- * </ul>
- *
- * @param the $html
- *
- * @throws Html2TextException
- * @internal param \the $html input HTML
- * @return the HTML converted, as best as possible, to text
+ * This file is available if you still want to use functions rather than
+ * autoloading classes.
*/
-function convert_html_to_text($html)
-{
- $html = fix_newlines($html);
- $doc = new DOMDocument();
- if (!$doc->loadHTML($html)) {
- throw new Html2TextException("Could not load HTML - badly formed?", $html);
- }
+require_once(__DIR__ . "/src/Html2Text.php");
+require_once(__DIR__ . "/src/Html2TextException.php");
- $output = iterate_over_node($doc);
-
- // remove leading and trailing spaces on each line
- $output = preg_replace("/[ \t]*\n[ \t]*/im", "\n", $output);
-
- // remove leading and trailing whitespace
- $output = trim($output);
-
- return $output;
+function convert_html_to_text($html) {
+ return Html2Text\Html2Text::convert($html);
}
-/**
- * Unify newlines; in particular, \r\n becomes \n, and
- * then \r becomes \n. This means that all newlines (Unix, Windows, Mac)
- * all become \ns.
- *
- * @param text text with any number of \r, \r\n and \n combinations
- *
- * @return the fixed text
- */
-function fix_newlines($text)
-{
- // replace \r\n to \n
- $text = str_replace("\r\n", "\n", $text);
- // remove \rs
- $text = str_replace("\r", "\n", $text);
-
- return $text;
+function fix_newlines($text) {
+ return Html2Text\Html2Text::fixNewlines($text);
}
-
-/**
- * @param $node
- *
- * @return null|string
- */
-function next_child_name($node)
-{
- // get the next child
- $nextNode = $node->nextSibling;
- while ($nextNode != null) {
- if ($nextNode instanceof DOMElement) {
- break;
- }
- $nextNode = $nextNode->nextSibling;
- }
- $nextName = null;
- if ($nextNode instanceof DOMElement && $nextNode != null) {
- $nextName = strtolower($nextNode->nodeName);
- }
-
- return $nextName;
-}
-
-/**
- * @param $node
- *
- * @return null|string
- */
-function prev_child_name($node)
-{
- // get the previous child
- $nextNode = $node->previousSibling;
- while ($nextNode != null) {
- if ($nextNode instanceof DOMElement) {
- break;
- }
- $nextNode = $nextNode->previousSibling;
- }
- $nextName = null;
- if ($nextNode instanceof DOMElement && $nextNode != null) {
- $nextName = strtolower($nextNode->nodeName);
- }
-
- return $nextName;
-}
-
-/**
- * @param $node
- *
- * @return string
- */
-function iterate_over_node($node)
-{
- if ($node instanceof DOMText) {
- return preg_replace("/\\s+/im", " ", $node->wholeText);
- }
- if ($node instanceof DOMDocumentType) {
- // ignore
- return "";
- }
-
- $nextName = next_child_name($node);
- $prevName = prev_child_name($node);
-
- $name = strtolower($node->nodeName);
-
- // start whitespace
- switch ($name) {
- case "hr":
- return "------\n";
-
- case "style":
- case "head":
- case "title":
- case "meta":
- case "script":
- // ignore these tags
- return "";
-
- case "h1":
- case "h2":
- case "h3":
- case "h4":
- case "h5":
- case "h6":
- // add two newlines
- $output = "\n";
- break;
-
- case "p":
- case "div":
- // add one line
- $output = "\n";
- break;
-
- default:
- // print out contents of unknown tags
- $output = "";
- break;
- }
-
- // debug
- //$output .= "[$name,$nextName]";
-
- for ($i = 0; $i < $node->childNodes->length; ++$i) {
- $n = $node->childNodes->item($i);
-
- $text = iterate_over_node($n);
-
- $output .= $text;
- }
-
- // end whitespace
- switch ($name) {
- case "style":
- case "head":
- case "title":
- case "meta":
- case "script":
- // ignore these tags
- return "";
-
- case "h1":
- case "h2":
- case "h3":
- case "h4":
- case "h5":
- case "h6":
- $output .= "\n";
- break;
-
- case "p":
- case "br":
- // add one line
- if ($nextName != "div") {
- $output .= "\n";
- }
- break;
-
- case "div":
- // add one line only if the next child isn't a div
- if ($nextName != "div" && $nextName != null) {
- $output .= "\n";
- }
- break;
-
- case "a":
- // links are returned in [text](link) format
- $href = $node->getAttribute("href");
- if ($href == null) {
- // it doesn't link anywhere
- if ($node->getAttribute("name") != null) {
- $output = "[$output]";
- }
- } else {
- if ($href == $output) {
- // link to the same address: just use link
- $output;
- } else {
- // replace it
- $output = "[$output]($href)";
- }
- }
-
- // does the next node require additional whitespace?
- switch ($nextName) {
- case "h1":
- case "h2":
- case "h3":
- case "h4":
- case "h5":
- case "h6":
- $output .= "\n";
- break;
- }
-
- default:
- // do nothing
- }
-
- return $output;
-}
-
-/**
- * Class Html2TextException
- */
-class Html2TextException extends Exception
-{
- var $more_info;
-
- /**
- * @param string $message
- * @param string $more_info
- */
- public function __construct($message = "", $more_info = "")
- {
- parent::__construct($message);
- $this->more_info = $more_info;
- }
-}
Added: XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/src/Html2Text.php
===================================================================
--- XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/src/Html2Text.php (rev 0)
+++ XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/src/Html2Text.php 2015-02-16 19:07:35 UTC (rev 12985)
@@ -0,0 +1,240 @@
+<?php
+/******************************************************************************
+ * Copyright (c) 2010 Jevon Wright and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * or
+ *
+ * LGPL which is available at http://www.gnu.org/licenses/lgpl.html
+ *
+ *
+ * Contributors:
+ * Jevon Wright - initial API and implementation
+ ****************************************************************************/
+
+namespace Html2Text;
+
+class Html2Text {
+
+ /**
+ * Tries to convert the given HTML into a plain text format - best suited for
+ * e-mail display, etc.
+ *
+ * <p>In particular, it tries to maintain the following features:
+ * <ul>
+ * <li>Links are maintained, with the 'href' copied over
+ * <li>Information in the <head> is lost
+ * </ul>
+ *
+ * @param string html the input HTML
+ * @return string the HTML converted, as best as possible, to text
+ * @throws Html2TextException if the HTML could not be loaded as a {@link DOMDocument}
+ */
+ static function convert($html) {
+ $html = static::fixNewlines($html);
+
+ $doc = new \DOMDocument();
+ if (!$doc->loadHTML($html)) {
+ throw new Html2TextException("Could not load HTML - badly formed?", $html);
+ }
+
+ $output = static::iterateOverNode($doc);
+
+ // remove leading and trailing spaces on each line
+ $output = preg_replace("/[ \t]*\n[ \t]*/im", "\n", $output);
+
+ // remove leading and trailing whitespace
+ $output = trim($output);
+
+ return $output;
+ }
+
+ /**
+ * Unify newlines; in particular, \r\n becomes \n, and
+ * then \r becomes \n. This means that all newlines (Unix, Windows, Mac)
+ * all become \ns.
+ *
+ * @param string text text with any number of \r, \r\n and \n combinations
+ * @return string the fixed text
+ */
+ static function fixNewlines($text) {
+ // replace \r\n to \n
+ $text = str_replace("\r\n", "\n", $text);
+ // remove \rs
+ $text = str_replace("\r", "\n", $text);
+
+ return $text;
+ }
+
+ static function nextChildName($node) {
+ // get the next child
+ $nextNode = $node->nextSibling;
+ while ($nextNode != null) {
+ if ($nextNode instanceof \DOMElement) {
+ break;
+ }
+ $nextNode = $nextNode->nextSibling;
+ }
+ $nextName = null;
+ if ($nextNode instanceof \DOMElement && $nextNode != null) {
+ $nextName = strtolower($nextNode->nodeName);
+ }
+
+ return $nextName;
+ }
+
+ static function prevChildName($node) {
+ // get the previous child
+ $nextNode = $node->previousSibling;
+ while ($nextNode != null) {
+ if ($nextNode instanceof \DOMElement) {
+ break;
+ }
+ $nextNode = $nextNode->previousSibling;
+ }
+ $nextName = null;
+ if ($nextNode instanceof \DOMElement && $nextNode != null) {
+ $nextName = strtolower($nextNode->nodeName);
+ }
+
+ return $nextName;
+ }
+
+ static function iterateOverNode($node) {
+ if ($node instanceof \DOMText) {
+ // Replace whitespace characters with a space (equivilant to \s)
+ return preg_replace("/[\\t\\n\\f\\r ]+/im", " ", $node->wholeText);
+ }
+ if ($node instanceof \DOMDocumentType) {
+ // ignore
+ return "";
+ }
+
+ $nextName = static::nextChildName($node);
+ $prevName = static::prevChildName($node);
+
+ $name = strtolower($node->nodeName);
+
+ // start whitespace
+ switch ($name) {
+ case "hr":
+ return "------\n";
+
+ case "style":
+ case "head":
+ case "title":
+ case "meta":
+ case "script":
+ // ignore these tags
+ return "";
+
+ case "h1":
+ case "h2":
+ case "h3":
+ case "h4":
+ case "h5":
+ case "h6":
+ // add two newlines, second line is added below
+ $output = "\n";
+ break;
+
+ case "td":
+ case "th":
+ // add tab char to separate table fields
+ $output = "\t";
+ break;
+
+ case "tr":
+ case "p":
+ case "div":
+ // add one line
+ $output = "\n";
+ break;
+
+ default:
+ // print out contents of unknown tags
+ $output = "";
+ break;
+ }
+
+ // debug
+ //$output .= "[$name,$nextName]";
+
+ if (isset($node->childNodes)) {
+ for ($i = 0; $i < $node->childNodes->length; $i++) {
+ $n = $node->childNodes->item($i);
+
+ $text = static::iterateOverNode($n);
+
+ $output .= $text;
+ }
+ }
+
+ // end whitespace
+ switch ($name) {
+ case "style":
+ case "head":
+ case "title":
+ case "meta":
+ case "script":
+ // ignore these tags
+ return "";
+
+ case "h1":
+ case "h2":
+ case "h3":
+ case "h4":
+ case "h5":
+ case "h6":
+ $output .= "\n";
+ break;
+
+ case "p":
+ case "br":
+ // add one line
+ if ($nextName != "div")
+ $output .= "\n";
+ break;
+
+ case "div":
+ // add one line only if the next child isn't a div
+ if ($nextName != "div" && $nextName != null)
+ $output .= "\n";
+ break;
+
+ case "a":
+ // links are returned in [text](link) format
+ $href = $node->getAttribute("href");
+ if ($href == null) {
+ // it doesn't link anywhere
+ if ($node->getAttribute("name") != null) {
+ $output = "[$output]";
+ }
+ } else {
+ if ($href == $output || $href == "mailto:$output" || $href == "http://$output" || $href == "https://$output") {
+ // link to the same address: just use link
+ $output;
+ } else {
+ // replace it
+ $output = "[$output]($href)";
+ }
+ }
+
+ // does the next node require additional whitespace?
+ switch ($nextName) {
+ case "h1": case "h2": case "h3": case "h4": case "h5": case "h6":
+ $output .= "\n";
+ break;
+ }
+
+ default:
+ // do nothing
+ }
+
+ return $output;
+ }
+
+}
Added: XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/src/Html2TextException.php
===================================================================
--- XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/src/Html2TextException.php (rev 0)
+++ XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/html2text/src/Html2TextException.php 2015-02-16 19:07:35 UTC (rev 12985)
@@ -0,0 +1,28 @@
+<?php
+
+/******************************************************************************
+ * Copyright (c) 2010 Jevon Wright and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * or
+ *
+ * LGPL which is available at http://www.gnu.org/licenses/lgpl.html
+ *
+ *
+ * Contributors:
+ * Jevon Wright - initial API and implementation
+ ****************************************************************************/
+
+namespace Html2Text;
+
+class Html2TextException extends \Exception {
+ var $more_info;
+
+ public function __construct($message = "", $more_info = "") {
+ parent::__construct($message);
+ $this->more_info = $more_info;
+ }
+}
Modified: XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/PHPMailerAutoload.php
===================================================================
--- XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/PHPMailerAutoload.php 2015-02-16 19:00:46 UTC (rev 12984)
+++ XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/PHPMailerAutoload.php 2015-02-16 19:07:35 UTC (rev 12985)
@@ -2,31 +2,29 @@
/**
* PHPMailer SPL autoloader.
* PHP Version 5
- *
- * @package PHPMailer
- * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
- * @author Marcus Bointon (Synchro/coolbru) <php...@sy...>
- * @author Jim Jagielski (jimjag) <ji...@gm...>
- * @author Andy Prevost (codeworxtech) <cod...@us...>
- * @author Brent R. Matzelle (original founder)
+ * @package PHPMailer
+ * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
+ * @author Marcus Bointon (Synchro/coolbru) <php...@sy...>
+ * @author Jim Jagielski (jimjag) <ji...@gm...>
+ * @author Andy Prevost (codeworxtech) <cod...@us...>
+ * @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2014 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
- * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
- * @note This program is distributed in the hope that it will be useful - WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
+ * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
+ * @note This program is distributed in the hope that it will be useful - WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* PHPMailer SPL autoloader.
- *
* @param string $classname The name of the class to load
*/
function PHPMailerAutoload($classname)
{
- //Can't use __DIR__ as it's only in PHP 5.3+
- $filename = __DIR__ . DIRECTORY_SEPARATOR . 'class.' . strtolower($classname) . '.php';
+ //Can't use __DIR__ as it's only in PHP 5.3+
+ $filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
if (is_readable($filename)) {
require $filename;
}
@@ -42,7 +40,6 @@
} else {
/**
* Fall back to traditional autoload for old PHP versions
- *
* @param string $classname The name of the class to load
*/
function __autoload($classname)
Modified: XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/class.phpmailer.php
===================================================================
--- XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/class.phpmailer.php 2015-02-16 19:00:46 UTC (rev 12984)
+++ XoopsModules/xnewsletter/branches/luciorota/xnewsletter/include/phpmailer/class.phpmailer.php 2015-02-16 19:07:35 UTC (rev 12985)
@@ -2,58 +2,52 @@
/**
* PHPMailer - PHP email creation and transport class.
* PHP Version 5
- *
- * @package PHPMailer
- * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
- * @author Marcus Bointon (Synchro/coolbru) <php...@sy...>
- * @author Jim Jagielski (jimjag) <ji...@gm...>
- * @author Andy Prevost (codeworxtech) <cod...@us...>
- * @author Brent R. Matzelle (original founder)
+ * @package PHPMailer
+ * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
+ * @author Marcus Bointon (Synchro/coolbru) <php...@sy...>
+ * @author Jim Jagielski (jimjag) <ji...@gm...>
+ * @author Andy Prevost (codeworxtech) <cod...@us...>
+ * @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2014 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
- * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
- * @note This program is distributed in the hope that it will be useful - WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
+ * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
+ * @note This program is distributed in the hope that it will be useful - WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* PHPMailer - PHP email creation and transport class.
- *
* @package PHPMailer
- * @author Marcus Bointon (Synchro/coolbru) <php...@sy...>
- * @author Jim Jagielski (jimjag) <ji...@gm...>
- * @author Andy Prevost (codeworxtech) <cod...@us...>
- * @author Brent R. Matzelle (original founder)
+ * @author Marcus Bointon (Synchro/coolbru) <php...@sy...>
+ * @author Jim Jagielski (jimjag) <ji...@gm...>
+ * @author Andy Prevost (codeworxtech) <cod...@us...>
+ * @author Brent R. Matzelle (original founder)
*/
class PHPMailer
{
/**
* The PHPMailer Version number.
- *
* @type string
*/
- public $Version = '5.2.8';
+ public $Version = '5.2.9';
/**
* Email priority.
* Options: 1 = High, 3 = Normal, 5 = low.
- *
* @type integer
*/
public $Priority = 3;
/**
* The character set of the message.
- *
* @type string
*/
public $CharSet = 'iso-8859-1';
/**
* The MIME Content-type of the message.
- *
* @type string
*/
public $ContentType = 'text/plain';
@@ -61,28 +55,24 @@
/**
* The message encoding.
* Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
- *
* @type string
*/
public $Encoding = '8bit';
/**
* Holds the most recent mailer error message.
- *
* @type string
*/
public $ErrorInfo = '';
/**
* The From email address for the message.
- *
* @type string
*/
public $From = 'root@localhost';
/**
* The From name of the message.
- *
* @type string
*/
public $FromName = 'Root User';
@@ -90,7 +80,6 @@
/**
* The Sender email (Return-Path) of the message.
* If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
- *
* @type string
*/
public $Sender = '';
@@ -98,17 +87,15 @@
/**
* The Return-Path of the message.
* If empty, it will be set to either From or Sender.
- *
* @type string
* @deprecated Email senders should never set a return-path header;
- * it's the receiver's job (RFC5321 section 4.4), so this no longer does anything.
- * @link https://tools.ietf.org/html/rfc5321#section-4.4 RFC5321 reference
+ * it's the receiver's job (RFC5321 section 4.4), so this no longer does anything.
+ * @link https://tools.ietf.org/html/rfc5321#section-4.4 RFC5321 reference
*/
public $ReturnPath = '';
/**
* The Subject of the message.
- *
* @type string
*/
public $Subject = '';
@@ -116,7 +103,6 @@
/**
* An HTML or plain text message body.
* If HTML then call isHTML(true).
- *
* @type string
*/
public $Body = '';
@@ -126,7 +112,6 @@
* This body can be read by mail clients that do not have HTML email
* capability such as mutt & Eudora.
* Clients that can read HTML will view the normal Body.
- *
* @type string
*/
public $AltBody = '';
@@ -135,7 +120,6 @@
* An iCal message part body.
* Only supported in simple alt or alt_inline message types
* To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator
- *
* @link http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/
* @link http://kigkonsult.se/iCalcreator/
* @type string
@@ -144,7 +128,6 @@
/**
* The complete compiled MIME message body.
- *
* @access protected
* @type string
*/
@@ -152,7 +135,6 @@
/**
* The complete compiled MIME message headers.
- *
* @type string
* @access protected
*/
@@ -160,7 +142,6 @@
/**
* Extra headers that createHeader() doesn't fold in.
- *
* @type string
* @access protected
*/
@@ -168,7 +149,7 @@
/**
* Word-wrap the message body to this number of chars.
- *
+ * Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
* @type integer
*/
public $WordWrap = 0;
@@ -176,14 +157,12 @@
/**
* Which method to use to send mail.
* Options: "mail", "sendmail", or "smtp".
- *
* @type string
*/
public $Mailer = 'mail';
/**
* The path to the sendmail program.
- *
* @type string
*/
public $Sendmail = '/usr/sbin/sendmail';
@@ -191,7 +170,6 @@
/**
* Whether mail() uses a fully sendmail-compatible MTA.
* One which supports sendmail's "-oi -f" options.
- *
* @type boolean
*/
public $UseSendmailOptions = true;
@@ -199,7 +177,6 @@
/**
* Path to PHPMailer plugins.
* Useful if the SMTP class is not in the PHP include path.
- *
* @type string
* @deprecated Should not be needed now there is an autoloader.
*/
@@ -207,7 +184,6 @@
/**
* The email address that a reading confirmation should be sent to.
- *
* @type string
*/
public $ConfirmReadingTo = '';
@@ -217,7 +193,6 @@
* and as default HELO string.
* If empty, the value returned
* by SERVER_NAME is used or 'localhost.localdomain'.
- *
* @type string
*/
public $Hostname = '';
@@ -225,7 +200,6 @@
/**
* An ID to be used in the Message-Id header.
* If empty, a unique id will be generated.
- *
* @type string
*/
public $MessageID = '';
@@ -233,7 +207,6 @@
/**
* The message Date to be used in the Date header.
* If empty, the current date will be added.
- *
* @type string
*/
public $MessageDate = '';
@@ -247,14 +220,12 @@
* You can also specify encryption type, for example:
* (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465").
* Hosts will be tried in order.
- *
* @type string
*/
public $Host = 'localhost';
/**
* The default SMTP server port.
- *
* @type integer
* @TODO Why is this needed when the SMTP class takes care of it?
*/
@@ -263,7 +234,6 @@
/**
* The SMTP HELO of the message.
* Default is $Hostname.
- *
* @type string
* @see PHPMailer::$Hostname
*/
@@ -272,7 +242,6 @@
/**
* The secure connection prefix.
* Options: "", "ssl" or "tls"
- *
* @type string
*/
public $SMTPSecure = '';
@@ -280,7 +249,6 @@
/**
* Whether to use SMTP authentication.
* Uses the Username and Password properties.
- *
* @type boolean
* @see PHPMailer::$Username
* @see PHPMailer::$Password
@@ -289,14 +257,12 @@
/**
* SMTP username.
- *
* @type string
*/
public $Username = '';
/**
* SMTP password.
- *
* @type string
*/
public $Password = '';
@@ -304,7 +270,6 @@
/**
* SMTP auth type.
* Options are LOGIN (default), PLAIN, NTLM, CRAM-MD5
- *
* @type string
*/
public $AuthType = '';
@@ -312,7 +277,6 @@
/**
* SMTP realm.
* Used for NTLM auth
- *
* @type string
*/
public $Realm = '';
@@ -320,17 +284,16 @@
/**
* SMTP workstation.
* Used for NTLM auth
- *
* @type string
*/
public $Workstation = '';
/**
* The SMTP server timeout in seconds.
- *
+ * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
* @type integer
*/
- public $Timeout = 10;
+ public $Timeout = 300;
/**
* SMTP class debug output mode.
@@ -341,7 +304,6 @@
* * `2` Data and commands
* * `3` As 2 plus connection status
* * `4` Low-level data output
- *
* @type integer
* @see SMTP::$do_debug
*/
@@ -358,7 +320,6 @@
* <code>
* $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
* </code>
- *
* @type string|callable
* @see SMTP::$Debugoutput
*/
@@ -368,7 +329,6 @@
* Whether to keep SMTP connection open after each message.
* If this is set to true then to close the connection
* requires an explicit call to smtpClose().
- *
* @type boolean
*/
public $SMTPKeepAlive = false;
@@ -376,14 +336,12 @@
/**
* Whether to split multiple to addresses into multiple messages
* or send them all in one message.
- *
* @type boolean
*/
public $SingleTo = false;
/**
* Storage for addresses when SingleTo is enabled.
- *
* @type array
* @TODO This should really not be public
*/
@@ -392,7 +350,6 @@
/**
* Whether to generate VERP addresses on send.
* Only applicable when sending via SMTP.
- *
* @link http://en.wikipedia.org/wiki/Variable_envelope_return_path
* @link http://www.postfix.org/VERP_README.html Postfix VERP info
* @type boolean
@@ -401,15 +358,13 @@
/**
* Whether to allow sending messages with an empty body.
- *
* @type boolean
*/
public $AllowEmpty = false;
/**
* The default line ending.
- *
- * @note The default remains "\n". We force CRLF where we know
+ * @note The default remains "\n". We force CRLF where we know
* it must be used via self::CRLF.
* @type string
*/
@@ -417,7 +372,6 @@
/**
* DKIM selector.
- *
* @type string
*/
public $DKIM_selector = '';
@@ -425,7 +379,6 @@
/**
* DKIM Identity.
* Usually the email address used as the source of the email
- *
* @type string
*/
public $DKIM_identity = '';
@@ -433,14 +386,12 @@
/**
* DKIM passphrase.
* Used if your key is encrypted.
- *
* @type string
*/
public $DKIM_passphrase = '';
/**
* DKIM signing domain name.
- *
* @example 'example.com'
* @type string
*/
@@ -448,7 +399,6 @@
/**
* DKIM private key file path.
- *
* @type string
*/
public $DKIM_private = '';
@@ -469,22 +419,19 @@
* string $subject the subject
* string $body the email body
* string $from email address of sender
- *
* @type string
*/
public $action_function = '';
/**
- * What to use in the X-Mailer header.
- * Options: null for default, whitespace for none, or a string to use
- *
+ * What to put in the X-Mailer header.
+ * Options: An empty string for PHPMailer default, whitespace for none, or a string to use
* @type string
*/
public $XMailer = '';
/**
* An instance of the SMTP sender class.
- *
* @type SMTP
* @access protected
*/
@@ -492,7 +439,6 @@
/**
* The array of 'to' addresses.
- *
* @type array
* @access protected
*/
@@ -500,7 +446,6 @@
/**
* The array of 'cc' addresses.
- *
* @type array
* @access protected
*/
@@ -508,7 +453,6 @@
/**
* The array of 'bcc' addresses.
- *
* @type array
* @access protected
*/
@@ -516,7 +460,6 @@
/**
* The array of reply-to names and addresses.
- *
* @type array
* @access protected
*/
@@ -525,7 +468,6 @@
/**
* An array of all kinds of addresses.
* Includes all of $to, $cc, $bcc, $replyto
- *
* @type array
* @access protected
*/
@@ -533,7 +475,6 @@
/**
* The array of attachments.
- *
* @type array
* @access protected
*/
@@ -541,7 +482,6 @@
/**
* The array of custom headers.
- *
* @type array
* @access protected
*/
@@ -549,7 +489,6 @@
/**
* The most recent Message-ID (including angular brackets).
- *
* @type string
* @access protected
*/
@@ -557,7 +496,6 @@
/**
* The message's MIME type.
- *
* @type string
* @access protected
*/
@@ -565,7 +503,6 @@
/**
* The array of MIME boundary strings.
- *
* @type array
* @access protected
*/
@@ -573,7 +510,6 @@
/**
* The array of available languages.
- *
* @type array
* @access protected
*/
@@ -581,7 +517,6 @@
/**
* The number of errors encountered.
- *
* @type integer
* @access protected
*/
@@ -589,7 +524,6 @@
/**
* The S/MIME certificate file path.
- *
* @type string
* @access protected
*/
@@ -597,7 +531,6 @@
/**
* The S/MIME key file path.
- *
* @type string
* @access protected
*/
@@ -606,7 +539,6 @@
/**
* The S/MIME password for the key.
* Used only if the key is encrypted.
- *
* @type string
* @access protected
*/
@@ -614,7 +546,6 @@
/**
* Whether to throw exceptions for errors.
- *
* @type boolean
* @access protected
*/
@@ -642,19 +573,11 @@
/**
* Constructor.
- *
* @param boolean $exceptions Should we throw external exceptions?
*/
public function __construct($exceptions = false)
{
- $this->exceptions = ($exceptions == true);
- //Make sure our autoloader is loaded
- if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
- $autoload = spl_autoload_functions();
- if ($autoload === false or !in_array('PHPMailerAutoload', $autoload)) {
- require 'PHPMailerAutoload.php';
- }
- }
+ $this->exceptions = (boolean)$exceptions;
}
/**
@@ -672,13 +595,11 @@
* Also, unless sendmail_path points to sendmail (or something that
* claims to be sendmail), don't pass params (not a perfect fix,
* but it will do)
- *
- * @param string $to To
+ * @param string $to To
* @param string $subject Subject
- * @param string $body Message Body
- * @param string $header Additional Header(s)
- * @param string $params Params
- *
+ * @param string $body Message Body
+ * @param string $header Additional Header(s)
+ * @param string $params Params
* @access private
* @return boolean
*/
@@ -695,17 +616,14 @@
} else {
$result = @mail($to, $subject, $body, $header, $params);
}
-
return $result;
}
/**
* Output debugging info via user-defined method.
* Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug).
- *
* @see PHPMailer::$Debugoutput
* @see PHPMailer::$SMTPDebug
- *
* @param string $str
*/
protected function edebug($str)
@@ -713,9 +631,9 @@
if ($this->SMTPDebug <= 0) {
return;
}
- if (is_callable($this->Debugoutput)) {
+ //Avoid clash with built-in function names
+ if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) {
call_user_func($this->Debugoutput, $str, $this->SMTPDebug);
-
return;
}
switch ($this->Debugoutput) {
@@ -726,28 +644,27 @@
case 'html':
//Cleans up output a bit for a better looking, HTML-safe output
echo htmlentities(
- preg_replace('/[\r\n]+/', '', $str),
- ENT_QUOTES,
- 'UTF-8'
- ) . "<br>\n";
+ preg_replace('/[\r\n]+/', '', $str),
+ ENT_QUOTES,
+ 'UTF-8'
+ )
+ . "<br>\n";
break;
case 'echo':
default:
//Normalize line breaks
$str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str);
echo gmdate('Y-m-d H:i:s') . "\t" . str_replace(
- "\n",
- "\n \t ",
- trim($str)
- ) . "\n";
+ "\n",
+ "\n \t ",
+ trim($str)
+ ) . "\n";
}
}
/**
* Sets message type to HTML or plain.
- *
* @param boolean $isHtml True for HTML mode.
- *
* @return void
*/
public function isHTML($isHtml = true)
@@ -761,7 +678,6 @@
/**
* Send messages using SMTP.
- *
* @return void
*/
public function isSMTP()
@@ -771,7 +687,6 @@
/**
* Send messages using PHP's mail() function.
- *
* @return void
*/
public function isMail()
@@ -781,7 +696,6 @@
/**
* Send messages using $Sendmail.
- *
* @return void
*/
public function isSendmail()
@@ -798,7 +712,6 @@
/**
* Send messages using qmail.
- *
* @return void
*/
public function isQmail()
@@ -815,10 +728,8 @@
/**
* Add a "To" address.
- *
* @param string $address
* @param string $name
- *
* @return boolean true on success, false if address already used
*/
public function addAddress($address, $name = '')
@@ -828,12 +739,9 @@
/**
* Add a "CC" address.
- *
* @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
- *
* @param string $address
* @param string $name
- *
* @return boolean true on success, false if address already used
*/
public function addCC($address, $name = '')
@@ -843,12 +751,9 @@
/**
* Add a "BCC" address.
- *
* @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
- *
* @param string $address
* @param string $name
- *
* @return boolean true on success, false if address already used
*/
public function addBCC($address, $name = '')
@@ -858,10 +763,8 @@
/**
* Add a "Reply-to" address.
- *
* @param string $address
* @param string $name
- *
* @return boolean
*/
public function addReplyTo($address, $name = '')
@@ -872,13 +775,11 @@
/**
* Add an address to one of the recipient arrays.
* Addresses that have been added already return false, but do not throw exceptions
- *
- * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo'
+ * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo'
* @param string $address The email address to send to
* @param string $name
- *
* @throws phpmailerException
- * @return boolean true on success, false if address already used or invalid in some way
+ * @return boolean true on success, false if address already used or invalid in some way
* @access protected
*/
protected function addAnAddress($kind, $address, $name = '')
@@ -889,69 +790,60 @@
if ($this->exceptions) {
throw new phpmailerException('Invalid recipient array: ' . $kind);
}
-
return false;
}
$address = trim($address);
- $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
+ $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (!$this->validateAddress($address)) {
$this->setError($this->lang('invalid_address') . ': ' . $address);
$this->edebug($this->lang('invalid_address') . ': ' . $address);
if ($this->exceptions) {
throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
}
-
return false;
}
if ($kind != 'Reply-To') {
if (!isset($this->all_recipients[strtolower($address)])) {
array_push($this->$kind, array($address, $name));
$this->all_recipients[strtolower($address)] = true;
-
return true;
}
} else {
if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
$this->ReplyTo[strtolower($address)] = array($address, $name);
-
return true;
}
}
-
return false;
}
/**
* Set the From and FromName properties.
- *
- * @param string $address
- * @param string $name
- * @param boolean $auto Whether to also set the Sender address, defaults to true
- *
+ * @param string $address
+ * @param string $name
+ * @param boolean $auto Whether to also set the Sender address, defaults to true
* @throws phpmailerException
* @return boolean
*/
public function setFrom($address, $name = '', $auto = true)
{
$address = trim($address);
- $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
+ $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (!$this->validateAddress($address)) {
$this->setError($this->lang('invalid_address') . ': ' . $address);
$this->edebug($this->lang('invalid_address') . ': ' . $address);
if ($this->exceptions) {
throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
}
-
return false;
}
- $this->From = $address;
+ $this->From = $address;
$this->FromName = $name;
if ($auto) {
if (empty($this->Sender)) {
$this->Sender = $address;
}
}
-
return true;
}
@@ -960,7 +852,6 @@
* Technically this is the value from the last time the headers were created,
* but it's also the message ID of the last sent message except in
* pathological cases.
- *
* @return string
*/
public function getLastMessageID()
@@ -970,16 +861,14 @@
/**
* Check that a string looks like an email address.
- *
- * @param string $address The email address to check
+ * @param string $address The email address to check
* @param string $patternselect A selector for the validation pattern to use :
- * * `auto` Pick strictest one automatically;
- * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14;
- * * `pcre` Use old PCRE implementation;
- * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; same as pcre8 but does not allow 'dotless' domains;
- * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements.
- * * `noregex` Don't use a regex: super fast, really dumb.
- *
+ * * `auto` Pick strictest one automatically;
+ * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14;
+ * * `pcre` Use old PCRE implementation;
+ * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; same as pcre8 but does not allow 'dotless' domains;
+ * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements.
+ * * `noregex` Don't use a regex: super fast, really dumb.
* @return boolean
* @static
* @access public
@@ -1012,48 +901,53 @@
case 'pcre8':
/**
* Uses the same RFC5322 regex on which FILTER_VALIDATE_EMAIL is based, but allows dotless domains.
- *
- * @link http://squiloople.com/2009/12/20/email-address-validation/
+ * @link http://squiloople.com/2009/12/20/email-address-validation/
* @copyright 2009-2010 Michael Rushton
- * Feel free to use and redistribute this code. But please keep this copyright notice.
+ * Feel free to use and redistribute this code. But please keep this copyright notice.
*/
-
return (boolean)preg_match(
- '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' . '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)'
- . '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)'
- . '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*'
- . '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)'
- . '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}'
- . '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:'
- . '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' . '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD',
+ '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' .
+ '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' .
+ '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' .
+ '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' .
+ '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' .
+ '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' .
+ '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' .
+ '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
+ '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD',
$address
);
case 'pcre':
//An older regex that doesn't need a recent PCRE
return (boolean)preg_match(
- '/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' . '[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")'
- . '(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*'
- . '@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})' . '(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:'
- . '[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?' . '::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:'
- . '[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?' . '::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}'
- . '|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))...
[truncated message content] |