dependabot-linguist 0.0.1 → 0.212.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +25 -3
- data/Gemfile +0 -9
- data/Gemfile.lock +162 -5
- data/LICENSE +674 -1
- data/{LICENSE.Nonstandard → LICENSE.dependabot-core} +0 -0
- data/Makefile +8 -1
- data/README.md +39 -5
- data/demo_script.rb +50 -0
- data/dependabot-linguist.gemspec +16 -5
- data/devlog.md +186 -0
- data/exe/dependabot-linguist +145 -0
- data/lib/dependabot/linguist/dependabot_file_validator.rb +190 -0
- data/lib/dependabot/linguist/dependabot_patch.rb +8 -0
- data/lib/dependabot/linguist/file_fetchers/base.rb +48 -0
- data/lib/dependabot/linguist/file_fetchers/git_submodules.rb +63 -0
- data/lib/dependabot/linguist/file_fetchers/go_modules.rb +41 -0
- data/lib/dependabot/linguist/language.rb +62 -0
- data/lib/dependabot/linguist/languages_to_ecosystems/contexts.rb +234 -0
- data/lib/dependabot/linguist/languages_to_ecosystems/contexts_applied.rb +36 -0
- data/lib/dependabot/linguist/languages_to_ecosystems/languages.yaml +7950 -0
- data/lib/dependabot/linguist/languages_to_ecosystems/main.rb +55 -0
- data/lib/dependabot/linguist/languages_to_ecosystems/manager_ecosystem_maps.rb +154 -0
- data/lib/dependabot/linguist/languages_to_patch.txt +37 -0
- data/lib/dependabot/linguist/linguist_patch.rb +6 -0
- data/lib/dependabot/linguist/repository.rb +232 -0
- data/lib/dependabot/linguist/version.rb +1 -1
- data/lib/dependabot/linguist.rb +5 -2
- data/smoke-test/README.md +58 -0
- data/smoke-test/bundler/Gemfile +9 -0
- data/smoke-test/bundler/Gemfile.lock +47 -0
- data/smoke-test/bundler/dependabot-all-updates-test-staging.gemspec +10 -0
- data/smoke-test/cargo/Cargo.lock +90 -0
- data/smoke-test/cargo/Cargo.toml +8 -0
- data/smoke-test/composer/composer.json +5 -0
- data/smoke-test/composer/composer.lock +72 -0
- data/smoke-test/composer/vendor/autoload.php +7 -0
- data/smoke-test/composer/vendor/composer/ClassLoader.php +445 -0
- data/smoke-test/composer/vendor/composer/LICENSE +21 -0
- data/smoke-test/composer/vendor/composer/autoload_classmap.php +13 -0
- data/smoke-test/composer/vendor/composer/autoload_namespaces.php +9 -0
- data/smoke-test/composer/vendor/composer/autoload_psr4.php +9 -0
- data/smoke-test/composer/vendor/composer/autoload_real.php +55 -0
- data/smoke-test/composer/vendor/composer/autoload_static.php +23 -0
- data/smoke-test/composer/vendor/composer/installed.json +57 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/.gitignore +3 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/LICENSE +504 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/README.md +112 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/changelog.md +530 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/class.phpmailer.php +2758 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/class.pop3.php +417 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/class.smtp.php +1075 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/composer.json +32 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/Callback_function_notes.txt +17 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/DomainKeys_notes.txt +55 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/Note_for_SMTP_debugging.txt +23 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/extending.html +148 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/faq.html +67 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/generatedocs.sh +4 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/pop3_article.txt +39 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/use_gmail.txt +44 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/contents.html +20 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/images/phpmailer.gif +0 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/images/phpmailer_mini.gif +0 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/index.html +50 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_db_smtp_basic.php +58 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_mail_advanced.php +30 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_mail_basic.php +41 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_pop_before_smtp_advanced.php +39 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_pop_before_smtp_basic.php +49 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_sendmail_advanced.php +33 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_sendmail_basic.php +43 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_smtp_advanced.php +42 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_smtp_advanced_no_auth.php +36 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_smtp_basic.php +58 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_smtp_basic_no_auth.php +53 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_smtp_gmail_advanced.php +42 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_smtp_gmail_basic.php +59 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/extras/class.html2text.inc +489 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/extras/htmlfilter.php +861 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/extras/ntlm_sasl_client.php +185 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-ar.php +26 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-br.php +25 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-ca.php +25 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-ch.php +25 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-cz.php +24 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-de.php +24 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-dk.php +25 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-es.php +25 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-et.php +25 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-fi.php +26 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-fo.php +26 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-fr.php +24 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-hu.php +24 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-it.php +26 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-ja.php +25 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-nl.php +24 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-no.php +24 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-pl.php +24 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-ro.php +26 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-ru.php +24 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-se.php +25 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-sk.php +25 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-tr.php +26 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-zh.php +25 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-zh_cn.php +25 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test/contents.html +10 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test/phpmailerTest.php +1084 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test/test.png +0 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test/test_callback.php +84 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test/testemail.php +48 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/LGPLv3.txt +165 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/contents.html +14 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/images/aikido.gif +0 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/images/bkgrnd.gif +0 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/images/phpmailer.gif +0 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/index.php +427 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/clipboard.swf +0 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushBash.js +59 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushCSharp.js +64 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushCpp.js +99 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushCss.js +93 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushDelphi.js +57 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushDiff.js +43 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushGroovy.js +69 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushJScript.js +51 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushJava.js +55 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushPerl.js +74 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushPhp.js +91 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushPlain.js +35 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushPython.js +56 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushRuby.js +57 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushScala.js +53 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushSql.js +68 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushVb.js +58 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushXml.js +71 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shCore.js +30 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shLegacy.js +30 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/src/shCore.js +1949 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/src/shLegacy.js +172 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/help.png +0 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/magnifier.png +0 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/page_white_code.png +0 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/page_white_copy.png +0 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/printer.png +0 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shCore.css +321 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shThemeDefault.css +191 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shThemeDjango.css +193 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shThemeEmacs.css +192 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shThemeFadeToGrey.css +193 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shThemeMidnight.css +192 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shThemeRDark.css +192 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/wrapping.png +0 -0
- data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/test.html +46 -0
- data/smoke-test/dependabot-file/no-config/.github/TARGET.yaml +14 -0
- data/smoke-test/dependabot-file/no-config/bundler/Gemfile +9 -0
- data/smoke-test/dependabot-file/no-config/bundler/Gemfile.lock +47 -0
- data/smoke-test/dependabot-file/no-config/bundler/dependabot-all-updates-test-staging.gemspec +10 -0
- data/smoke-test/dependabot-file/no-config/cargo/Cargo.lock +90 -0
- data/smoke-test/dependabot-file/no-config/cargo/Cargo.toml +8 -0
- data/smoke-test/dependabot-file/no-config/composer/composer.json +5 -0
- data/smoke-test/dependabot-file/no-config/composer/composer.lock +72 -0
- data/smoke-test/dependabot-file/over-config/.github/TARGET.yaml +17 -0
- data/smoke-test/dependabot-file/over-config/.github/dependabot.yaml +12 -0
- data/smoke-test/dependabot-file/over-config/bundler/Gemfile +9 -0
- data/smoke-test/dependabot-file/over-config/bundler/Gemfile.lock +47 -0
- data/smoke-test/dependabot-file/over-config/bundler/dependabot-all-updates-test-staging.gemspec +10 -0
- data/smoke-test/dependabot-file/over-config/cargo/Cargo.lock +90 -0
- data/smoke-test/dependabot-file/over-config/cargo/Cargo.toml +8 -0
- data/smoke-test/dependabot-file/over-config/composer/composer.json +5 -0
- data/smoke-test/dependabot-file/over-config/composer/composer.lock +72 -0
- data/smoke-test/dependabot-file/overer-config/.github/TARGET.yaml +19 -0
- data/smoke-test/dependabot-file/overer-config/.github/dependabot.yaml +12 -0
- data/smoke-test/dependabot-file/overer-config/bundler/Gemfile +9 -0
- data/smoke-test/dependabot-file/overer-config/bundler/Gemfile.lock +47 -0
- data/smoke-test/dependabot-file/overer-config/bundler/dependabot-all-updates-test-staging.gemspec +10 -0
- data/smoke-test/dependabot-file/overer-config/cargo/Cargo.lock +90 -0
- data/smoke-test/dependabot-file/overer-config/cargo/Cargo.toml +8 -0
- data/smoke-test/dependabot-file/overer-config/composer/composer.json +5 -0
- data/smoke-test/dependabot-file/overer-config/composer/composer.lock +72 -0
- data/smoke-test/dependabot-file/partial-config/.github/TARGET.yaml +17 -0
- data/smoke-test/dependabot-file/partial-config/.github/dependabot.yaml +7 -0
- data/smoke-test/dependabot-file/partial-config/bundler/Gemfile +9 -0
- data/smoke-test/dependabot-file/partial-config/bundler/Gemfile.lock +47 -0
- data/smoke-test/dependabot-file/partial-config/bundler/dependabot-all-updates-test-staging.gemspec +10 -0
- data/smoke-test/dependabot-file/partial-config/cargo/Cargo.lock +90 -0
- data/smoke-test/dependabot-file/partial-config/cargo/Cargo.toml +8 -0
- data/smoke-test/dependabot-file/partial-config/composer/composer.json +5 -0
- data/smoke-test/dependabot-file/partial-config/composer/composer.lock +72 -0
- data/smoke-test/docker/Dockerfile +19 -0
- data/smoke-test/elm/elm-package.json +15 -0
- data/smoke-test/elm/elm.json +31 -0
- data/smoke-test/github-actions/both/.github/workflows/this.yaml +11 -0
- data/smoke-test/github-actions/both/yaml/action.yml +13 -0
- data/smoke-test/github-actions/invalid/invalid_file.yaml +0 -0
- data/smoke-test/github-actions/workflow/.github/workflows/this.yaml +11 -0
- data/smoke-test/github-actions/yaml/action.yml +13 -0
- data/smoke-test/gitsubmodule/.gitmodules +4 -0
- data/smoke-test/gomod/go.mod +16 -0
- data/smoke-test/gomod/go.sum +18 -0
- data/smoke-test/gomod/gomain.go +14 -0
- data/smoke-test/gradle/.gitignore +1 -0
- data/smoke-test/gradle/build.gradle +65 -0
- data/smoke-test/maven/pom.xml +65 -0
- data/smoke-test/mix/mix.exs +24 -0
- data/smoke-test/mix/mix.lock +5 -0
- data/smoke-test/npm/package-lock.json +166 -0
- data/smoke-test/npm/package.json +22 -0
- data/smoke-test/npm/removed/package-lock.json +44 -0
- data/smoke-test/npm/removed/package.json +15 -0
- data/smoke-test/nuget/project.csproj +14 -0
- data/smoke-test/pip/pip/requirements.txt +5 -0
- data/smoke-test/pip/pip-compile/requirements.in +2 -0
- data/smoke-test/pip/pip-compile/requirements.txt +16 -0
- data/smoke-test/pip/pipenv/Pipfile +13 -0
- data/smoke-test/pip/pipenv/Pipfile.lock +86 -0
- data/smoke-test/pip/poetry/poetry.lock +33 -0
- data/smoke-test/pip/poetry/pyproject.toml +18 -0
- data/smoke-test/pub/pubspec.lock +40 -0
- data/smoke-test/pub/pubspec.yaml +10 -0
- data/smoke-test/terraform/main.tf +143 -0
- metadata +314 -6
- data/LICENSE.GPL-3.0-only +0 -674
@@ -0,0 +1,1084 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* PHPMailer - PHP email transport unit tests
|
4
|
+
* Before running these tests you need to install PHPUnit 3.3 or later through pear, like this:
|
5
|
+
* pear install "channel://pear.phpunit.de/PHPUnit"
|
6
|
+
* Then run the tests like this:
|
7
|
+
* phpunit phpmailerTest
|
8
|
+
* @package PHPMailer
|
9
|
+
* @author Andy Prevost
|
10
|
+
* @author Marcus Bointon
|
11
|
+
* @copyright 2004 - 2009 Andy Prevost
|
12
|
+
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
13
|
+
*/
|
14
|
+
|
15
|
+
require 'PHPUnit/Autoload.php';
|
16
|
+
|
17
|
+
/**
|
18
|
+
* PHPMailer - PHP email transport unit test class
|
19
|
+
* Performs authentication tests
|
20
|
+
*/
|
21
|
+
class phpmailerTest extends PHPUnit_Framework_TestCase
|
22
|
+
{
|
23
|
+
/**
|
24
|
+
* Holds the default phpmailer instance.
|
25
|
+
* @private
|
26
|
+
* @var PHPMailer
|
27
|
+
*/
|
28
|
+
public $Mail;
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Holds the SMTP mail host.
|
32
|
+
* @public
|
33
|
+
* @var string
|
34
|
+
*/
|
35
|
+
public $Host = "";
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Holds the change log.
|
39
|
+
* @private
|
40
|
+
* @var string[]
|
41
|
+
*/
|
42
|
+
public $ChangeLog = array();
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Holds the note log.
|
46
|
+
* @private
|
47
|
+
* @var string[]
|
48
|
+
*/
|
49
|
+
public $NoteLog = array();
|
50
|
+
|
51
|
+
/**
|
52
|
+
* @var string Default include path
|
53
|
+
*/
|
54
|
+
public $INCLUDE_DIR = '../';
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Run before each test is started.
|
58
|
+
*/
|
59
|
+
function setUp()
|
60
|
+
{
|
61
|
+
|
62
|
+
if (file_exists('./testbootstrap.php')) {
|
63
|
+
include './testbootstrap.php'; //Overrides go in here
|
64
|
+
}
|
65
|
+
require_once $this->INCLUDE_DIR . 'class.phpmailer.php';
|
66
|
+
$this->Mail = new PHPMailer;
|
67
|
+
|
68
|
+
$this->Mail->Priority = 3;
|
69
|
+
$this->Mail->Encoding = "8bit";
|
70
|
+
$this->Mail->CharSet = "iso-8859-1";
|
71
|
+
if (array_key_exists('mail_from', $_REQUEST)) {
|
72
|
+
$this->Mail->From = $_REQUEST['mail_from'];
|
73
|
+
} else {
|
74
|
+
$this->Mail->From = 'unit_test@phpmailer.example.com';
|
75
|
+
}
|
76
|
+
$this->Mail->FromName = "Unit Tester";
|
77
|
+
$this->Mail->Sender = "";
|
78
|
+
$this->Mail->Subject = "Unit Test";
|
79
|
+
$this->Mail->Body = "";
|
80
|
+
$this->Mail->AltBody = "";
|
81
|
+
$this->Mail->WordWrap = 0;
|
82
|
+
if (array_key_exists('mail_host', $_REQUEST)) {
|
83
|
+
$this->Mail->Host = $_REQUEST['mail_host'];
|
84
|
+
} else {
|
85
|
+
$this->Mail->Host = 'mail.example.com';
|
86
|
+
}
|
87
|
+
if (array_key_exists('mail_port', $_REQUEST)) {
|
88
|
+
$this->Mail->Port = $_REQUEST['mail_port'];
|
89
|
+
} else {
|
90
|
+
$this->Mail->Port = 25;
|
91
|
+
}
|
92
|
+
$this->Mail->Helo = "localhost.localdomain";
|
93
|
+
$this->Mail->SMTPAuth = false;
|
94
|
+
$this->Mail->Username = "";
|
95
|
+
$this->Mail->Password = "";
|
96
|
+
$this->Mail->PluginDir = $this->INCLUDE_DIR;
|
97
|
+
$this->Mail->AddReplyTo("no_reply@phpmailer.example.com", "Reply Guy");
|
98
|
+
$this->Mail->Sender = "unit_test@phpmailer.example.com";
|
99
|
+
|
100
|
+
if (strlen($this->Mail->Host) > 0) {
|
101
|
+
$this->Mail->Mailer = "smtp";
|
102
|
+
} else {
|
103
|
+
$this->Mail->Mailer = "mail";
|
104
|
+
$this->Mail->Sender = "unit_test@phpmailer.example.com";
|
105
|
+
}
|
106
|
+
|
107
|
+
if (array_key_exists('mail_to', $_REQUEST)) {
|
108
|
+
$this->SetAddress($_REQUEST['mail_to'], 'Test User', 'to');
|
109
|
+
}
|
110
|
+
if (array_key_exists('mail_cc', $_REQUEST) and strlen($_REQUEST['mail_cc']) > 0) {
|
111
|
+
$this->SetAddress($_REQUEST['mail_cc'], 'Carbon User', 'cc');
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Run after each test is completed.
|
117
|
+
*/
|
118
|
+
function tearDown()
|
119
|
+
{
|
120
|
+
// Clean global variables
|
121
|
+
$this->Mail = null;
|
122
|
+
$this->ChangeLog = array();
|
123
|
+
$this->NoteLog = array();
|
124
|
+
}
|
125
|
+
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Build the body of the message in the appropriate format.
|
129
|
+
* @private
|
130
|
+
* @returns void
|
131
|
+
*/
|
132
|
+
function BuildBody()
|
133
|
+
{
|
134
|
+
$this->CheckChanges();
|
135
|
+
|
136
|
+
// Determine line endings for message
|
137
|
+
if ($this->Mail->ContentType == "text/html" || strlen($this->Mail->AltBody) > 0) {
|
138
|
+
$eol = "<br/>";
|
139
|
+
$bullet = "<li>";
|
140
|
+
$bullet_start = "<ul>";
|
141
|
+
$bullet_end = "</ul>";
|
142
|
+
} else {
|
143
|
+
$eol = "\n";
|
144
|
+
$bullet = " - ";
|
145
|
+
$bullet_start = "";
|
146
|
+
$bullet_end = "";
|
147
|
+
}
|
148
|
+
|
149
|
+
$ReportBody = "";
|
150
|
+
|
151
|
+
$ReportBody .= "---------------------" . $eol;
|
152
|
+
$ReportBody .= "Unit Test Information" . $eol;
|
153
|
+
$ReportBody .= "---------------------" . $eol;
|
154
|
+
$ReportBody .= "phpmailer version: " . $this->Mail->Version . $eol;
|
155
|
+
$ReportBody .= "Content Type: " . $this->Mail->ContentType . $eol;
|
156
|
+
|
157
|
+
if (strlen($this->Mail->Host) > 0) {
|
158
|
+
$ReportBody .= "Host: " . $this->Mail->Host . $eol;
|
159
|
+
}
|
160
|
+
|
161
|
+
// If attachments then create an attachment list
|
162
|
+
$attachments = $this->Mail->GetAttachments();
|
163
|
+
if (count($attachments) > 0) {
|
164
|
+
$ReportBody .= "Attachments:" . $eol;
|
165
|
+
$ReportBody .= $bullet_start;
|
166
|
+
foreach ($attachments as $attachment) {
|
167
|
+
$ReportBody .= $bullet . "Name: " . $attachment[1] . ", ";
|
168
|
+
$ReportBody .= "Encoding: " . $attachment[3] . ", ";
|
169
|
+
$ReportBody .= "Type: " . $attachment[4] . $eol;
|
170
|
+
}
|
171
|
+
$ReportBody .= $bullet_end . $eol;
|
172
|
+
}
|
173
|
+
|
174
|
+
// If there are changes then list them
|
175
|
+
if (count($this->ChangeLog) > 0) {
|
176
|
+
$ReportBody .= "Changes" . $eol;
|
177
|
+
$ReportBody .= "-------" . $eol;
|
178
|
+
|
179
|
+
$ReportBody .= $bullet_start;
|
180
|
+
for ($i = 0; $i < count($this->ChangeLog); $i++) {
|
181
|
+
$ReportBody .= $bullet . $this->ChangeLog[$i][0] . " was changed to [" .
|
182
|
+
$this->ChangeLog[$i][1] . "]" . $eol;
|
183
|
+
}
|
184
|
+
$ReportBody .= $bullet_end . $eol . $eol;
|
185
|
+
}
|
186
|
+
|
187
|
+
// If there are notes then list them
|
188
|
+
if (count($this->NoteLog) > 0) {
|
189
|
+
$ReportBody .= "Notes" . $eol;
|
190
|
+
$ReportBody .= "-----" . $eol;
|
191
|
+
|
192
|
+
$ReportBody .= $bullet_start;
|
193
|
+
for ($i = 0; $i < count($this->NoteLog); $i++) {
|
194
|
+
$ReportBody .= $bullet . $this->NoteLog[$i] . $eol;
|
195
|
+
}
|
196
|
+
$ReportBody .= $bullet_end;
|
197
|
+
}
|
198
|
+
|
199
|
+
// Re-attach the original body
|
200
|
+
$this->Mail->Body .= $eol . $eol . $ReportBody;
|
201
|
+
}
|
202
|
+
|
203
|
+
/**
|
204
|
+
* Check which default settings have been changed for the report.
|
205
|
+
* @private
|
206
|
+
* @returns void
|
207
|
+
*/
|
208
|
+
function CheckChanges()
|
209
|
+
{
|
210
|
+
if ($this->Mail->Priority != 3) {
|
211
|
+
$this->AddChange("Priority", $this->Mail->Priority);
|
212
|
+
}
|
213
|
+
if ($this->Mail->Encoding != "8bit") {
|
214
|
+
$this->AddChange("Encoding", $this->Mail->Encoding);
|
215
|
+
}
|
216
|
+
if ($this->Mail->CharSet != "iso-8859-1") {
|
217
|
+
$this->AddChange("CharSet", $this->Mail->CharSet);
|
218
|
+
}
|
219
|
+
if ($this->Mail->Sender != "") {
|
220
|
+
$this->AddChange("Sender", $this->Mail->Sender);
|
221
|
+
}
|
222
|
+
if ($this->Mail->WordWrap != 0) {
|
223
|
+
$this->AddChange("WordWrap", $this->Mail->WordWrap);
|
224
|
+
}
|
225
|
+
if ($this->Mail->Mailer != "mail") {
|
226
|
+
$this->AddChange("Mailer", $this->Mail->Mailer);
|
227
|
+
}
|
228
|
+
if ($this->Mail->Port != 25) {
|
229
|
+
$this->AddChange("Port", $this->Mail->Port);
|
230
|
+
}
|
231
|
+
if ($this->Mail->Helo != "localhost.localdomain") {
|
232
|
+
$this->AddChange("Helo", $this->Mail->Helo);
|
233
|
+
}
|
234
|
+
if ($this->Mail->SMTPAuth) {
|
235
|
+
$this->AddChange("SMTPAuth", "true");
|
236
|
+
}
|
237
|
+
}
|
238
|
+
|
239
|
+
/**
|
240
|
+
* Add a changelog entry.
|
241
|
+
* @access private
|
242
|
+
* @param string $sName
|
243
|
+
* @param string $sNewValue
|
244
|
+
* @return void
|
245
|
+
*/
|
246
|
+
function AddChange($sName, $sNewValue)
|
247
|
+
{
|
248
|
+
$this->ChangeLog[] = array($sName, $sNewValue);
|
249
|
+
}
|
250
|
+
|
251
|
+
/**
|
252
|
+
* Adds a simple note to the message.
|
253
|
+
* @public
|
254
|
+
* @param string $sValue
|
255
|
+
* @return void
|
256
|
+
*/
|
257
|
+
function AddNote($sValue)
|
258
|
+
{
|
259
|
+
$this->NoteLog[] = $sValue;
|
260
|
+
}
|
261
|
+
|
262
|
+
/**
|
263
|
+
* Adds all of the addresses
|
264
|
+
* @access public
|
265
|
+
* @param string $sAddress
|
266
|
+
* @param string $sName
|
267
|
+
* @param string $sType
|
268
|
+
* @return boolean
|
269
|
+
*/
|
270
|
+
function SetAddress($sAddress, $sName = '', $sType = 'to')
|
271
|
+
{
|
272
|
+
switch ($sType) {
|
273
|
+
case 'to':
|
274
|
+
return $this->Mail->AddAddress($sAddress, $sName);
|
275
|
+
case 'cc':
|
276
|
+
return $this->Mail->AddCC($sAddress, $sName);
|
277
|
+
case "bcc":
|
278
|
+
return $this->Mail->AddBCC($sAddress, $sName);
|
279
|
+
}
|
280
|
+
return false;
|
281
|
+
}
|
282
|
+
|
283
|
+
/////////////////////////////////////////////////
|
284
|
+
// UNIT TESTS
|
285
|
+
/////////////////////////////////////////////////
|
286
|
+
|
287
|
+
/**
|
288
|
+
* Test CRAM-MD5 authentication
|
289
|
+
* Needs a connection to a server that supports this auth mechanism, so commented out by default
|
290
|
+
*/
|
291
|
+
function testAuthCRAMMD5()
|
292
|
+
{
|
293
|
+
$this->Mail->Host = 'hostname';
|
294
|
+
$this->Mail->Port = 587;
|
295
|
+
$this->Mail->SMTPAuth = true;
|
296
|
+
$this->Mail->SMTPSecure = 'tls';
|
297
|
+
$this->Mail->AuthType = 'CRAM-MD5';
|
298
|
+
$this->Mail->Username = 'username';
|
299
|
+
$this->Mail->Password = 'password';
|
300
|
+
$this->Mail->Body = 'Test body';
|
301
|
+
$this->Mail->Subject .= ": Auth CRAM-MD5";
|
302
|
+
$this->Mail->From = 'from@example.com';
|
303
|
+
$this->Mail->Sender = 'from@example.com';
|
304
|
+
$this->Mail->ClearAllRecipients();
|
305
|
+
$this->Mail->AddAddress('user@example.com');
|
306
|
+
//$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
307
|
+
}
|
308
|
+
|
309
|
+
/**
|
310
|
+
* Test email address validation
|
311
|
+
* Test addresses obtained from http://isemail.info
|
312
|
+
* Some failing cases commented out, mostly not significant though
|
313
|
+
*/
|
314
|
+
function testValidate()
|
315
|
+
{
|
316
|
+
$validaddresses = array(
|
317
|
+
'first@iana.org',
|
318
|
+
'first.last@iana.org',
|
319
|
+
'1234567890123456789012345678901234567890123456789012345678901234@iana.org',
|
320
|
+
'"first\"last"@iana.org',
|
321
|
+
'"first@last"@iana.org',
|
322
|
+
'"first\last"@iana.org',
|
323
|
+
'first.last@[12.34.56.78]',
|
324
|
+
'first.last@[IPv6:::12.34.56.78]',
|
325
|
+
// 'first.last@[IPv6:1111:2222:3333::4444:12.34.56.78]',
|
326
|
+
'first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.56.78]',
|
327
|
+
'first.last@[IPv6:::1111:2222:3333:4444:5555:6666]',
|
328
|
+
'first.last@[IPv6:1111:2222:3333::4444:5555:6666]',
|
329
|
+
'first.last@[IPv6:1111:2222:3333:4444:5555:6666::]',
|
330
|
+
'first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888]',
|
331
|
+
'first.last@x23456789012345678901234567890123456789012345678901234567890123.iana.org',
|
332
|
+
'first.last@3com.com',
|
333
|
+
'first.last@123.iana.org',
|
334
|
+
'"first\last"@iana.org',
|
335
|
+
// 'first.last@[IPv6:1111:2222:3333::4444:5555:12.34.56.78]',
|
336
|
+
// 'first.last@[IPv6:1111:2222:3333::4444:5555:6666:7777]',
|
337
|
+
'first.last@example.123',
|
338
|
+
'first.last@com',
|
339
|
+
'"Abc\@def"@iana.org',
|
340
|
+
'"Fred\ Bloggs"@iana.org',
|
341
|
+
'"Joe.\Blow"@iana.org',
|
342
|
+
'"Abc@def"@iana.org',
|
343
|
+
'"Fred Bloggs"@iana.org',
|
344
|
+
'user+mailbox@iana.org',
|
345
|
+
'customer/department=shipping@iana.org',
|
346
|
+
'$A12345@iana.org',
|
347
|
+
'!def!xyz%abc@iana.org',
|
348
|
+
'_somename@iana.org',
|
349
|
+
'dclo@us.ibm.com',
|
350
|
+
'peter.piper@iana.org',
|
351
|
+
'"Doug \"Ace\" L."@iana.org',
|
352
|
+
'test@iana.org',
|
353
|
+
'TEST@iana.org',
|
354
|
+
'1234567890@iana.org',
|
355
|
+
'test+test@iana.org',
|
356
|
+
'test-test@iana.org',
|
357
|
+
't*est@iana.org',
|
358
|
+
'+1~1+@iana.org',
|
359
|
+
'{_test_}@iana.org',
|
360
|
+
'"[[ test ]]"@iana.org',
|
361
|
+
'test.test@iana.org',
|
362
|
+
'"test.test"@iana.org',
|
363
|
+
'test."test"@iana.org',
|
364
|
+
'"test@test"@iana.org',
|
365
|
+
'test@123.123.123.x123',
|
366
|
+
'test@123.123.123.123',
|
367
|
+
'test@[123.123.123.123]',
|
368
|
+
'test@example.iana.org',
|
369
|
+
'test@example.example.iana.org',
|
370
|
+
'"test\test"@iana.org',
|
371
|
+
'test@example',
|
372
|
+
'"test\blah"@iana.org',
|
373
|
+
'"test\blah"@iana.org',
|
374
|
+
'"test\"blah"@iana.org',
|
375
|
+
'customer/department@iana.org',
|
376
|
+
'_Yosemite.Sam@iana.org',
|
377
|
+
'~@iana.org',
|
378
|
+
'"Austin@Powers"@iana.org',
|
379
|
+
'Ima.Fool@iana.org',
|
380
|
+
'"Ima.Fool"@iana.org',
|
381
|
+
'"Ima Fool"@iana.org',
|
382
|
+
'"first"."last"@iana.org',
|
383
|
+
'"first".middle."last"@iana.org',
|
384
|
+
'"first".last@iana.org',
|
385
|
+
'first."last"@iana.org',
|
386
|
+
'"first"."middle"."last"@iana.org',
|
387
|
+
'"first.middle"."last"@iana.org',
|
388
|
+
'"first.middle.last"@iana.org',
|
389
|
+
'"first..last"@iana.org',
|
390
|
+
// '"first\\\"last"@iana.org',
|
391
|
+
'first."mid\dle"."last"@iana.org',
|
392
|
+
'"test blah"@iana.org',
|
393
|
+
// '(foo)cal(bar)@(baz)iamcal.com(quux)',
|
394
|
+
// 'cal@iamcal(woo).(yay)com',
|
395
|
+
// 'cal(woo(yay)hoopla)@iamcal.com',
|
396
|
+
// 'cal(foo\@bar)@iamcal.com',
|
397
|
+
// 'cal(foo\)bar)@iamcal.com',
|
398
|
+
// 'first().last@iana.org',
|
399
|
+
// 'pete(his account)@silly.test(his host)',
|
400
|
+
// 'c@(Chris\'s host.)public.example',
|
401
|
+
// 'jdoe@machine(comment). example',
|
402
|
+
// '1234 @ local(blah) .machine .example',
|
403
|
+
'first(abc.def).last@iana.org',
|
404
|
+
'first(a"bc.def).last@iana.org',
|
405
|
+
'first.(")middle.last(")@iana.org',
|
406
|
+
'first(abc\(def)@iana.org',
|
407
|
+
'first.last@x(1234567890123456789012345678901234567890123456789012345678901234567890).com',
|
408
|
+
'a(a(b(c)d(e(f))g)h(i)j)@iana.org',
|
409
|
+
'name.lastname@domain.com',
|
410
|
+
'a@b',
|
411
|
+
'a@bar.com',
|
412
|
+
'aaa@[123.123.123.123]',
|
413
|
+
'a@bar',
|
414
|
+
'a-b@bar.com',
|
415
|
+
'+@b.c',
|
416
|
+
'+@b.com',
|
417
|
+
'a@b.co-foo.uk',
|
418
|
+
'"hello my name is"@stutter.com',
|
419
|
+
'"Test \"Fail\" Ing"@iana.org',
|
420
|
+
'valid@about.museum',
|
421
|
+
'shaitan@my-domain.thisisminekthx',
|
422
|
+
'foobar@192.168.0.1',
|
423
|
+
'"Joe\Blow"@iana.org',
|
424
|
+
'HM2Kinsists@(that comments are allowed)this.is.ok',
|
425
|
+
'user%uucp!path@berkeley.edu',
|
426
|
+
'first.last @iana.org',
|
427
|
+
'cdburgess+!#$%&\'*-/=?+_{}|~test@gmail.com',
|
428
|
+
// 'first.last@[IPv6:::a2:a3:a4:b1:b2:b3:b4]',
|
429
|
+
// 'first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3::]',
|
430
|
+
'first.last@[IPv6:::]',
|
431
|
+
'first.last@[IPv6:::b4]',
|
432
|
+
'first.last@[IPv6:::b3:b4]',
|
433
|
+
'first.last@[IPv6:a1::b4]',
|
434
|
+
'first.last@[IPv6:a1::]',
|
435
|
+
'first.last@[IPv6:a1:a2::]',
|
436
|
+
'first.last@[IPv6:0123:4567:89ab:cdef::]',
|
437
|
+
'first.last@[IPv6:0123:4567:89ab:CDEF::]',
|
438
|
+
'first.last@[IPv6:::a3:a4:b1:ffff:11.22.33.44]',
|
439
|
+
// 'first.last@[IPv6:::a2:a3:a4:b1:ffff:11.22.33.44]',
|
440
|
+
'first.last@[IPv6:a1:a2:a3:a4::11.22.33.44]',
|
441
|
+
// 'first.last@[IPv6:a1:a2:a3:a4:b1::11.22.33.44]',
|
442
|
+
'first.last@[IPv6:a1::11.22.33.44]',
|
443
|
+
'first.last@[IPv6:a1:a2::11.22.33.44]',
|
444
|
+
'first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.44]',
|
445
|
+
'first.last@[IPv6:0123:4567:89ab:CDEF::11.22.33.44]',
|
446
|
+
'first.last@[IPv6:a1::b2:11.22.33.44]',
|
447
|
+
'test@test.com',
|
448
|
+
'test@xn--example.com',
|
449
|
+
'test@example.com'
|
450
|
+
);
|
451
|
+
$invalidaddresses = array(
|
452
|
+
'first.last@sub.do,com',
|
453
|
+
'first\@last@iana.org',
|
454
|
+
'123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234 [...]',
|
455
|
+
'first.last',
|
456
|
+
'12345678901234567890123456789012345678901234567890123456789012345@iana.org',
|
457
|
+
'.first.last@iana.org',
|
458
|
+
'first.last.@iana.org',
|
459
|
+
'first..last@iana.org',
|
460
|
+
'"first"last"@iana.org',
|
461
|
+
// '"""@iana.org',
|
462
|
+
'"\"@iana.org',
|
463
|
+
// '""@iana.org',
|
464
|
+
'first\@last@iana.org',
|
465
|
+
'first.last@',
|
466
|
+
'x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23 [...]',
|
467
|
+
'first.last@[.12.34.56.78]',
|
468
|
+
'first.last@[12.34.56.789]',
|
469
|
+
'first.last@[::12.34.56.78]',
|
470
|
+
'first.last@[IPv5:::12.34.56.78]',
|
471
|
+
'first.last@[IPv6:1111:2222:3333:4444:5555:12.34.56.78]',
|
472
|
+
'first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:12.34.56.78]',
|
473
|
+
'first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777]',
|
474
|
+
'first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999]',
|
475
|
+
'first.last@[IPv6:1111:2222::3333::4444:5555:6666]',
|
476
|
+
'first.last@[IPv6:1111:2222:333x::4444:5555]',
|
477
|
+
'first.last@[IPv6:1111:2222:33333::4444:5555]',
|
478
|
+
'first.last@-xample.com',
|
479
|
+
'first.last@exampl-.com',
|
480
|
+
'first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org',
|
481
|
+
'abc\@def@iana.org',
|
482
|
+
'abc\@iana.org',
|
483
|
+
'Doug\ \"Ace\"\ Lovell@iana.org',
|
484
|
+
'abc@def@iana.org',
|
485
|
+
'abc\@def@iana.org',
|
486
|
+
'abc\@iana.org',
|
487
|
+
'@iana.org',
|
488
|
+
'doug@',
|
489
|
+
'"qu@iana.org',
|
490
|
+
'ote"@iana.org',
|
491
|
+
'.dot@iana.org',
|
492
|
+
'dot.@iana.org',
|
493
|
+
'two..dot@iana.org',
|
494
|
+
'"Doug "Ace" L."@iana.org',
|
495
|
+
'Doug\ \"Ace\"\ L\.@iana.org',
|
496
|
+
'hello world@iana.org',
|
497
|
+
'gatsby@f.sc.ot.t.f.i.tzg.era.l.d.',
|
498
|
+
'test.iana.org',
|
499
|
+
'test.@iana.org',
|
500
|
+
'test..test@iana.org',
|
501
|
+
'.test@iana.org',
|
502
|
+
'test@test@iana.org',
|
503
|
+
'test@@iana.org',
|
504
|
+
'-- test --@iana.org',
|
505
|
+
'[test]@iana.org',
|
506
|
+
'"test"test"@iana.org',
|
507
|
+
'()[]\;:,><@iana.org',
|
508
|
+
'test@.',
|
509
|
+
'test@example.',
|
510
|
+
'test@.org',
|
511
|
+
'test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 [...]',
|
512
|
+
'test@[123.123.123.123',
|
513
|
+
'test@123.123.123.123]',
|
514
|
+
'NotAnEmail',
|
515
|
+
'@NotAnEmail',
|
516
|
+
'"test"blah"@iana.org',
|
517
|
+
'.wooly@iana.org',
|
518
|
+
'wo..oly@iana.org',
|
519
|
+
'pootietang.@iana.org',
|
520
|
+
'.@iana.org',
|
521
|
+
'Ima Fool@iana.org',
|
522
|
+
'phil.h\@\@ck@haacked.com',
|
523
|
+
'foo@[\1.2.3.4]',
|
524
|
+
// 'first."".last@iana.org',
|
525
|
+
'first\last@iana.org',
|
526
|
+
'Abc\@def@iana.org',
|
527
|
+
'Fred\ Bloggs@iana.org',
|
528
|
+
'Joe.\Blow@iana.org',
|
529
|
+
'first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.567.89]',
|
530
|
+
'{^c\@**Dog^}@cartoon.com',
|
531
|
+
// '"foo"(yay)@(hoopla)[1.2.3.4]',
|
532
|
+
'cal(foo(bar)@iamcal.com',
|
533
|
+
'cal(foo)bar)@iamcal.com',
|
534
|
+
'cal(foo\)@iamcal.com',
|
535
|
+
'first(12345678901234567890123456789012345678901234567890)last@(123456789012345678901234567890123456789012 [...]',
|
536
|
+
'first(middle)last@iana.org',
|
537
|
+
'first(abc("def".ghi).mno)middle(abc("def".ghi).mno).last@(abc("def".ghi).mno)example(abc("def".ghi).mno). [...]',
|
538
|
+
'a(a(b(c)d(e(f))g)(h(i)j)@iana.org',
|
539
|
+
'.@',
|
540
|
+
'@bar.com',
|
541
|
+
'@@bar.com',
|
542
|
+
'aaa.com',
|
543
|
+
'aaa@.com',
|
544
|
+
'aaa@.123',
|
545
|
+
'aaa@[123.123.123.123]a',
|
546
|
+
'aaa@[123.123.123.333]',
|
547
|
+
'a@bar.com.',
|
548
|
+
'a@-b.com',
|
549
|
+
'a@b-.com',
|
550
|
+
'-@..com',
|
551
|
+
'-@a..com',
|
552
|
+
'invalid@about.museum-',
|
553
|
+
'test@...........com',
|
554
|
+
// '"Unicode NULL "@char.com',
|
555
|
+
'Unicode NULL @char.com',
|
556
|
+
'first.last@[IPv6::]',
|
557
|
+
'first.last@[IPv6::::]',
|
558
|
+
'first.last@[IPv6::b4]',
|
559
|
+
'first.last@[IPv6::::b4]',
|
560
|
+
'first.last@[IPv6::b3:b4]',
|
561
|
+
'first.last@[IPv6::::b3:b4]',
|
562
|
+
'first.last@[IPv6:a1:::b4]',
|
563
|
+
'first.last@[IPv6:a1:]',
|
564
|
+
'first.last@[IPv6:a1:::]',
|
565
|
+
'first.last@[IPv6:a1:a2:]',
|
566
|
+
'first.last@[IPv6:a1:a2:::]',
|
567
|
+
'first.last@[IPv6::11.22.33.44]',
|
568
|
+
'first.last@[IPv6::::11.22.33.44]',
|
569
|
+
'first.last@[IPv6:a1:11.22.33.44]',
|
570
|
+
'first.last@[IPv6:a1:::11.22.33.44]',
|
571
|
+
'first.last@[IPv6:a1:a2:::11.22.33.44]',
|
572
|
+
'first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.xx]',
|
573
|
+
'first.last@[IPv6:0123:4567:89ab:CDEFF::11.22.33.44]',
|
574
|
+
'first.last@[IPv6:a1::a4:b1::b4:11.22.33.44]',
|
575
|
+
'first.last@[IPv6:a1::11.22.33]',
|
576
|
+
'first.last@[IPv6:a1::11.22.33.44.55]',
|
577
|
+
'first.last@[IPv6:a1::b211.22.33.44]',
|
578
|
+
'first.last@[IPv6:a1::b2::11.22.33.44]',
|
579
|
+
'first.last@[IPv6:a1::b3:]',
|
580
|
+
'first.last@[IPv6::a2::b4]',
|
581
|
+
'first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3:]',
|
582
|
+
'first.last@[IPv6::a2:a3:a4:b1:b2:b3:b4]',
|
583
|
+
'first.last@[IPv6:a1:a2:a3:a4::b1:b2:b3:b4]'
|
584
|
+
);
|
585
|
+
$goodfails = array();
|
586
|
+
foreach ($validaddresses as $address) {
|
587
|
+
if (!PHPMailer::ValidateAddress($address)) {
|
588
|
+
$goodfails[] = $address;
|
589
|
+
//"Valid address <$address> failed validation"
|
590
|
+
}
|
591
|
+
}
|
592
|
+
$badpasses = array();
|
593
|
+
foreach ($invalidaddresses as $address) {
|
594
|
+
if (PHPMailer::ValidateAddress($address)) {
|
595
|
+
$badpasses[] = $address;
|
596
|
+
}
|
597
|
+
}
|
598
|
+
$err = '';
|
599
|
+
if (count($goodfails) > 0) {
|
600
|
+
$err .= "Good addreses that failed validation:\n";
|
601
|
+
$err .= implode("\n", $goodfails);
|
602
|
+
}
|
603
|
+
if (count($badpasses) > 0) {
|
604
|
+
if (!empty($err)) {
|
605
|
+
$err .= "\n\n";
|
606
|
+
}
|
607
|
+
$err .= "Bad addreses that passed validation:\n";
|
608
|
+
$err .= implode("\n", $badpasses);
|
609
|
+
}
|
610
|
+
$this->assertEmpty($err, $err);
|
611
|
+
}
|
612
|
+
|
613
|
+
/**
|
614
|
+
* Try a plain message.
|
615
|
+
*/
|
616
|
+
function test_WordWrap()
|
617
|
+
{
|
618
|
+
|
619
|
+
$this->Mail->WordWrap = 40;
|
620
|
+
$my_body = "Here is the main body of this message. It should " .
|
621
|
+
"be quite a few lines. It should be wrapped at the " .
|
622
|
+
"40 characters. Make sure that it is.";
|
623
|
+
$nBodyLen = strlen($my_body);
|
624
|
+
$my_body .= "\n\nThis is the above body length: " . $nBodyLen;
|
625
|
+
|
626
|
+
$this->Mail->Body = $my_body;
|
627
|
+
$this->Mail->Subject .= ": Wordwrap";
|
628
|
+
|
629
|
+
$this->BuildBody();
|
630
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
631
|
+
}
|
632
|
+
|
633
|
+
/**
|
634
|
+
* Try a plain message.
|
635
|
+
*/
|
636
|
+
function test_Low_Priority()
|
637
|
+
{
|
638
|
+
|
639
|
+
$this->Mail->Priority = 5;
|
640
|
+
$this->Mail->Body = "Here is the main body. There should be " .
|
641
|
+
"a reply to address in this message.";
|
642
|
+
$this->Mail->Subject .= ": Low Priority";
|
643
|
+
$this->Mail->AddReplyTo("nobody@nobody.com", "Nobody (Unit Test)");
|
644
|
+
|
645
|
+
$this->BuildBody();
|
646
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
647
|
+
}
|
648
|
+
|
649
|
+
/**
|
650
|
+
* Simple plain file attachment test.
|
651
|
+
*/
|
652
|
+
function test_Multiple_Plain_FileAttachment()
|
653
|
+
{
|
654
|
+
|
655
|
+
$this->Mail->Body = "Here is the text body";
|
656
|
+
$this->Mail->Subject .= ": Plain + Multiple FileAttachments";
|
657
|
+
|
658
|
+
if (!$this->Mail->AddAttachment("test.png")) {
|
659
|
+
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
660
|
+
return;
|
661
|
+
}
|
662
|
+
|
663
|
+
if (!$this->Mail->AddAttachment(__FILE__, "test.txt")) {
|
664
|
+
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
665
|
+
return;
|
666
|
+
}
|
667
|
+
|
668
|
+
$this->BuildBody();
|
669
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
670
|
+
}
|
671
|
+
|
672
|
+
/**
|
673
|
+
* Simple plain string attachment test.
|
674
|
+
*/
|
675
|
+
function test_Plain_StringAttachment()
|
676
|
+
{
|
677
|
+
|
678
|
+
$this->Mail->Body = "Here is the text body";
|
679
|
+
$this->Mail->Subject .= ": Plain + StringAttachment";
|
680
|
+
|
681
|
+
$sAttachment = "These characters are the content of the " .
|
682
|
+
"string attachment.\nThis might be taken from a " .
|
683
|
+
"database or some other such thing. ";
|
684
|
+
|
685
|
+
$this->Mail->AddStringAttachment($sAttachment, "string_attach.txt");
|
686
|
+
|
687
|
+
$this->BuildBody();
|
688
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
689
|
+
}
|
690
|
+
|
691
|
+
/**
|
692
|
+
* Plain quoted-printable message.
|
693
|
+
*/
|
694
|
+
function test_Quoted_Printable()
|
695
|
+
{
|
696
|
+
|
697
|
+
$this->Mail->Body = "Here is the main body";
|
698
|
+
$this->Mail->Subject .= ": Plain + Quoted-printable";
|
699
|
+
$this->Mail->Encoding = "quoted-printable";
|
700
|
+
|
701
|
+
$this->BuildBody();
|
702
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
703
|
+
|
704
|
+
//Check that a quoted printable encode and decode results in the same as went in
|
705
|
+
$t = file_get_contents(__FILE__); //Use this file as test content
|
706
|
+
$this->assertEquals(
|
707
|
+
$t,
|
708
|
+
quoted_printable_decode($this->Mail->EncodeQP($t)),
|
709
|
+
'Quoted-Printable encoding round-trip failed'
|
710
|
+
);
|
711
|
+
$this->assertEquals($this->Mail->EncodeQP($t), $this->Mail->EncodeQPphp($t), 'Quoted-Printable BC wrapper failed');
|
712
|
+
}
|
713
|
+
|
714
|
+
/**
|
715
|
+
* Try a plain message.
|
716
|
+
*/
|
717
|
+
function test_Html()
|
718
|
+
{
|
719
|
+
|
720
|
+
$this->Mail->IsHTML(true);
|
721
|
+
$this->Mail->Subject .= ": HTML only";
|
722
|
+
|
723
|
+
$this->Mail->Body = "This is a <b>test message</b> written in HTML. </br>" .
|
724
|
+
"Go to <a href=\"http://phpmailer.sourceforge.net/\">" .
|
725
|
+
"http://phpmailer.sourceforge.net/</a> for new versions of " .
|
726
|
+
"phpmailer. <p/> Thank you!";
|
727
|
+
|
728
|
+
$this->BuildBody();
|
729
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
730
|
+
}
|
731
|
+
|
732
|
+
/**
|
733
|
+
* Simple HTML and attachment test
|
734
|
+
*/
|
735
|
+
function test_HTML_Attachment()
|
736
|
+
{
|
737
|
+
|
738
|
+
$this->Mail->Body = "This is the <strong>HTML</strong> part of the email.";
|
739
|
+
$this->Mail->Subject .= ": HTML + Attachment";
|
740
|
+
$this->Mail->IsHTML(true);
|
741
|
+
|
742
|
+
if (!$this->Mail->AddAttachment(__FILE__, "test_attach.txt")) {
|
743
|
+
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
744
|
+
return;
|
745
|
+
}
|
746
|
+
|
747
|
+
$this->BuildBody();
|
748
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
749
|
+
}
|
750
|
+
|
751
|
+
/**
|
752
|
+
* An embedded attachment test.
|
753
|
+
*/
|
754
|
+
function test_Embedded_Image()
|
755
|
+
{
|
756
|
+
|
757
|
+
$this->Mail->Body = "Embedded Image: <img alt=\"phpmailer\" src=\"cid:my-attach\">" .
|
758
|
+
"Here is an image!</a>";
|
759
|
+
$this->Mail->Subject .= ": Embedded Image";
|
760
|
+
$this->Mail->IsHTML(true);
|
761
|
+
|
762
|
+
if (!$this->Mail->AddEmbeddedImage(
|
763
|
+
"test.png",
|
764
|
+
"my-attach",
|
765
|
+
"test.png",
|
766
|
+
"base64",
|
767
|
+
"image/png"
|
768
|
+
)
|
769
|
+
) {
|
770
|
+
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
771
|
+
return;
|
772
|
+
}
|
773
|
+
|
774
|
+
$this->BuildBody();
|
775
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
776
|
+
//For code coverage
|
777
|
+
$this->Mail->AddEmbeddedImage('thisfiledoesntexist', 'xyz'); //Non-existent file
|
778
|
+
$this->Mail->AddEmbeddedImage(__FILE__, '123'); //Missing name
|
779
|
+
|
780
|
+
}
|
781
|
+
|
782
|
+
/**
|
783
|
+
* An embedded attachment test.
|
784
|
+
*/
|
785
|
+
function test_Multi_Embedded_Image()
|
786
|
+
{
|
787
|
+
|
788
|
+
$this->Mail->Body = "Embedded Image: <img alt=\"phpmailer\" src=\"cid:my-attach\">" .
|
789
|
+
"Here is an image!</a>";
|
790
|
+
$this->Mail->Subject .= ": Embedded Image + Attachment";
|
791
|
+
$this->Mail->IsHTML(true);
|
792
|
+
|
793
|
+
if (!$this->Mail->AddEmbeddedImage(
|
794
|
+
"test.png",
|
795
|
+
"my-attach",
|
796
|
+
"test.png",
|
797
|
+
"base64",
|
798
|
+
"image/png"
|
799
|
+
)
|
800
|
+
) {
|
801
|
+
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
802
|
+
return;
|
803
|
+
}
|
804
|
+
|
805
|
+
if (!$this->Mail->AddAttachment(__FILE__, "test.txt")) {
|
806
|
+
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
807
|
+
return;
|
808
|
+
}
|
809
|
+
|
810
|
+
$this->BuildBody();
|
811
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
812
|
+
}
|
813
|
+
|
814
|
+
/**
|
815
|
+
* Simple multipart/alternative test.
|
816
|
+
*/
|
817
|
+
function test_AltBody()
|
818
|
+
{
|
819
|
+
|
820
|
+
$this->Mail->Body = "This is the <strong>HTML</strong> part of the email.";
|
821
|
+
$this->Mail->AltBody = "Here is the text body of this message. " .
|
822
|
+
"It should be quite a few lines. It should be wrapped at the " .
|
823
|
+
"40 characters. Make sure that it is.";
|
824
|
+
$this->Mail->WordWrap = 40;
|
825
|
+
$this->AddNote("This is a mulipart alternative email");
|
826
|
+
$this->Mail->Subject .= ": AltBody + Word Wrap";
|
827
|
+
|
828
|
+
$this->BuildBody();
|
829
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
830
|
+
}
|
831
|
+
|
832
|
+
/**
|
833
|
+
* Simple HTML and attachment test
|
834
|
+
*/
|
835
|
+
function test_AltBody_Attachment()
|
836
|
+
{
|
837
|
+
|
838
|
+
$this->Mail->Body = "This is the <strong>HTML</strong> part of the email.";
|
839
|
+
$this->Mail->AltBody = "This is the text part of the email.";
|
840
|
+
$this->Mail->Subject .= ": AltBody + Attachment";
|
841
|
+
$this->Mail->IsHTML(true);
|
842
|
+
|
843
|
+
if (!$this->Mail->AddAttachment(__FILE__, "test_attach.txt")) {
|
844
|
+
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
845
|
+
return;
|
846
|
+
}
|
847
|
+
|
848
|
+
$this->BuildBody();
|
849
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
850
|
+
if (is_writable('.')) {
|
851
|
+
file_put_contents('message.txt', $this->Mail->CreateHeader() . $this->Mail->CreateBody());
|
852
|
+
} else {
|
853
|
+
$this->assertTrue(false, 'Could not write local file - check permissions');
|
854
|
+
}
|
855
|
+
}
|
856
|
+
|
857
|
+
/**
|
858
|
+
* Test sending multiple messages with separate connections
|
859
|
+
*/
|
860
|
+
function test_MultipleSend()
|
861
|
+
{
|
862
|
+
$this->Mail->Body = "Sending two messages without keepalive";
|
863
|
+
$this->BuildBody();
|
864
|
+
$subject = $this->Mail->Subject;
|
865
|
+
|
866
|
+
$this->Mail->Subject = $subject . ": SMTP 1";
|
867
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
868
|
+
|
869
|
+
$this->Mail->Subject = $subject . ": SMTP 2";
|
870
|
+
$this->Mail->Sender = 'blah@example.com';
|
871
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
872
|
+
}
|
873
|
+
|
874
|
+
/**
|
875
|
+
* Test sending using SendMail
|
876
|
+
*/
|
877
|
+
function test_SendmailSend()
|
878
|
+
{
|
879
|
+
$this->Mail->Body = "Sending via sendmail";
|
880
|
+
$this->BuildBody();
|
881
|
+
$subject = $this->Mail->Subject;
|
882
|
+
|
883
|
+
$this->Mail->Subject = $subject . ": sendmail";
|
884
|
+
$this->Mail->IsSendmail();
|
885
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
886
|
+
}
|
887
|
+
|
888
|
+
/**
|
889
|
+
* Test sending using PHP mail() function
|
890
|
+
*/
|
891
|
+
function test_MailSend()
|
892
|
+
{
|
893
|
+
$this->Mail->Body = "Sending via mail()";
|
894
|
+
$this->BuildBody();
|
895
|
+
$subject = $this->Mail->Subject;
|
896
|
+
|
897
|
+
$this->Mail->Subject = $subject . ": mail()";
|
898
|
+
$this->Mail->IsMail();
|
899
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
900
|
+
}
|
901
|
+
|
902
|
+
/**
|
903
|
+
* Test keepalive (sending multiple messages in a single connection)
|
904
|
+
*/
|
905
|
+
function test_SmtpKeepAlive()
|
906
|
+
{
|
907
|
+
$this->Mail->Body = "This was done using the SMTP keep-alive.";
|
908
|
+
$this->BuildBody();
|
909
|
+
$subject = $this->Mail->Subject;
|
910
|
+
|
911
|
+
$this->Mail->SMTPKeepAlive = true;
|
912
|
+
$this->Mail->Subject = $subject . ": SMTP keep-alive 1";
|
913
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
914
|
+
|
915
|
+
$this->Mail->Subject = $subject . ": SMTP keep-alive 2";
|
916
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
917
|
+
$this->Mail->SmtpClose();
|
918
|
+
}
|
919
|
+
|
920
|
+
/**
|
921
|
+
* Tests this denial of service attack:
|
922
|
+
* http://www.cybsec.com/vuln/PHPMailer-DOS.pdf
|
923
|
+
*/
|
924
|
+
function test_DenialOfServiceAttack()
|
925
|
+
{
|
926
|
+
$this->Mail->Body = "This should no longer cause a denial of service.";
|
927
|
+
$this->BuildBody();
|
928
|
+
|
929
|
+
$this->Mail->Subject = str_repeat("A", 998);
|
930
|
+
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
931
|
+
}
|
932
|
+
|
933
|
+
/**
|
934
|
+
* Test error handling
|
935
|
+
*/
|
936
|
+
function test_Error()
|
937
|
+
{
|
938
|
+
$this->Mail->Subject .= ": This should be sent";
|
939
|
+
$this->BuildBody();
|
940
|
+
$this->Mail->ClearAllRecipients(); // no addresses should cause an error
|
941
|
+
$this->assertTrue($this->Mail->IsError() == false, "Error found");
|
942
|
+
$this->assertTrue($this->Mail->Send() == false, "Send succeeded");
|
943
|
+
$this->assertTrue($this->Mail->IsError(), "No error found");
|
944
|
+
$this->assertEquals('You must provide at least one recipient email address.', $this->Mail->ErrorInfo);
|
945
|
+
$this->Mail->AddAddress($_REQUEST['mail_to']);
|
946
|
+
$this->assertTrue($this->Mail->Send(), "Send failed");
|
947
|
+
}
|
948
|
+
|
949
|
+
/**
|
950
|
+
* Test addressing
|
951
|
+
*/
|
952
|
+
function test_Addressing()
|
953
|
+
{
|
954
|
+
$this->assertFalse($this->Mail->AddAddress('a@example..com'), 'Invalid address accepted');
|
955
|
+
$this->assertTrue($this->Mail->AddAddress('a@example.com'), 'Addressing failed');
|
956
|
+
$this->assertFalse($this->Mail->AddAddress('a@example.com'), 'Duplicate addressing failed');
|
957
|
+
$this->assertTrue($this->Mail->AddCC('b@example.com'), 'CC addressing failed');
|
958
|
+
$this->assertFalse($this->Mail->AddCC('b@example.com'), 'CC duplicate addressing failed');
|
959
|
+
$this->assertFalse($this->Mail->AddCC('a@example.com'), 'CC duplicate addressing failed (2)');
|
960
|
+
$this->assertTrue($this->Mail->AddBCC('c@example.com'), 'BCC addressing failed');
|
961
|
+
$this->assertFalse($this->Mail->AddBCC('c@example.com'), 'BCC duplicate addressing failed');
|
962
|
+
$this->assertFalse($this->Mail->AddBCC('a@example.com'), 'BCC duplicate addressing failed (2)');
|
963
|
+
$this->assertTrue($this->Mail->AddReplyTo('a@example.com'), 'Replyto Addressing failed');
|
964
|
+
$this->assertFalse($this->Mail->AddReplyTo('a@example..com'), 'Invalid Replyto address accepted');
|
965
|
+
$this->Mail->ClearAddresses();
|
966
|
+
$this->Mail->ClearCCs();
|
967
|
+
$this->Mail->ClearBCCs();
|
968
|
+
$this->Mail->ClearReplyTos();
|
969
|
+
}
|
970
|
+
|
971
|
+
/**
|
972
|
+
* Test language files for missing and excess translations
|
973
|
+
* All languages are compared with English
|
974
|
+
*/
|
975
|
+
function test_Translations()
|
976
|
+
{
|
977
|
+
$this->Mail->SetLanguage('en');
|
978
|
+
$definedStrings = $this->Mail->GetTranslations();
|
979
|
+
$err = '';
|
980
|
+
foreach (new DirectoryIterator('../language') as $fileInfo) {
|
981
|
+
if ($fileInfo->isDot()) {
|
982
|
+
continue;
|
983
|
+
}
|
984
|
+
$matches = array();
|
985
|
+
//Only look at language files, ignore anything else in there
|
986
|
+
if (preg_match('/^phpmailer\.lang-([a-z_]{2,})\.php$/', $fileInfo->getFilename(), $matches)) {
|
987
|
+
$lang = $matches[1]; //Extract language code
|
988
|
+
$PHPMAILER_LANG = array(); //Language strings get put in here
|
989
|
+
include $fileInfo->getPathname(); //Get language strings
|
990
|
+
$missing = array_diff(array_keys($definedStrings), array_keys($PHPMAILER_LANG));
|
991
|
+
$extra = array_diff(array_keys($PHPMAILER_LANG), array_keys($definedStrings));
|
992
|
+
if (!empty($missing)) {
|
993
|
+
$err .= "Missing translations in $lang: " . implode(', ', $missing) . "\n";
|
994
|
+
}
|
995
|
+
if (!empty($extra)) {
|
996
|
+
$err .= "Extra translations in $lang: " . implode(', ', $extra) . "\n";
|
997
|
+
}
|
998
|
+
}
|
999
|
+
}
|
1000
|
+
$this->assertEmpty($err, $err);
|
1001
|
+
}
|
1002
|
+
|
1003
|
+
/**
|
1004
|
+
* Encoding tests
|
1005
|
+
*/
|
1006
|
+
function test_Encodings()
|
1007
|
+
{
|
1008
|
+
$this->Mail->CharSet = 'iso-8859-1';
|
1009
|
+
$this->assertEquals(
|
1010
|
+
'=A1Hola!_Se=F1or!',
|
1011
|
+
$this->Mail->EncodeQ('�Hola! Se�or!', 'text'),
|
1012
|
+
'Q Encoding (text) failed'
|
1013
|
+
);
|
1014
|
+
$this->assertEquals(
|
1015
|
+
'=A1Hola!_Se=F1or!',
|
1016
|
+
$this->Mail->EncodeQ('�Hola! Se�or!', 'comment'),
|
1017
|
+
'Q Encoding (comment) failed'
|
1018
|
+
);
|
1019
|
+
$this->assertEquals(
|
1020
|
+
'=A1Hola!_Se=F1or!',
|
1021
|
+
$this->Mail->EncodeQ('�Hola! Se�or!', 'phrase'),
|
1022
|
+
'Q Encoding (phrase) failed'
|
1023
|
+
);
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
/**
|
1027
|
+
* Signing tests
|
1028
|
+
*/
|
1029
|
+
function test_Signing()
|
1030
|
+
{
|
1031
|
+
$this->Mail->Sign(
|
1032
|
+
'certfile.txt',
|
1033
|
+
'keyfile.txt',
|
1034
|
+
'password'
|
1035
|
+
); //TODO this is not really testing signing, but at least helps coverage
|
1036
|
+
}
|
1037
|
+
|
1038
|
+
/**
|
1039
|
+
* Miscellaneous calls to improve test coverage and some small tests
|
1040
|
+
*/
|
1041
|
+
function test_Miscellaneous()
|
1042
|
+
{
|
1043
|
+
$this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed');
|
1044
|
+
$this->Mail->AddCustomHeader('SomeHeader: Some Value');
|
1045
|
+
$this->Mail->ClearCustomHeaders();
|
1046
|
+
$this->Mail->ClearAttachments();
|
1047
|
+
$this->Mail->IsHTML(false);
|
1048
|
+
$this->Mail->IsSMTP();
|
1049
|
+
$this->Mail->IsMail();
|
1050
|
+
$this->Mail->IsSendMail();
|
1051
|
+
$this->Mail->IsQmail();
|
1052
|
+
$this->Mail->SetLanguage('fr');
|
1053
|
+
$this->Mail->Sender = '';
|
1054
|
+
$this->Mail->CreateHeader();
|
1055
|
+
$this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded');
|
1056
|
+
$this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed');
|
1057
|
+
}
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
/**
|
1061
|
+
* This is a sample form for setting appropriate test values through a browser
|
1062
|
+
* These values can also be set using a file called testbootstrap.php (not in svn) in the same folder as this script
|
1063
|
+
* which is probably more useful if you run these tests a lot
|
1064
|
+
<html>
|
1065
|
+
<body>
|
1066
|
+
<h3>phpmailer Unit Test</h3>
|
1067
|
+
By entering a SMTP hostname it will automatically perform tests with SMTP.
|
1068
|
+
|
1069
|
+
<form name="phpmailer_unit" action=__FILE__ method="get">
|
1070
|
+
<input type="hidden" name="submitted" value="1"/>
|
1071
|
+
From Address: <input type="text" size="50" name="mail_from" value="<?php echo get("mail_from"); ?>"/>
|
1072
|
+
<br/>
|
1073
|
+
To Address: <input type="text" size="50" name="mail_to" value="<?php echo get("mail_to"); ?>"/>
|
1074
|
+
<br/>
|
1075
|
+
Cc Address: <input type="text" size="50" name="mail_cc" value="<?php echo get("mail_cc"); ?>"/>
|
1076
|
+
<br/>
|
1077
|
+
SMTP Hostname: <input type="text" size="50" name="mail_host" value="<?php echo get("mail_host"); ?>"/>
|
1078
|
+
<p/>
|
1079
|
+
<input type="submit" value="Run Test"/>
|
1080
|
+
|
1081
|
+
</form>
|
1082
|
+
</body>
|
1083
|
+
</html>
|
1084
|
+
*/
|