dependabot-linguist 0.212.0 → 0.212.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +7 -7
  3. data/README.md +27 -0
  4. data/dependabot-linguist.gemspec +1 -1
  5. data/lib/dependabot/linguist/dependabot_file_validator.rb +40 -6
  6. data/lib/dependabot/linguist/version.rb +1 -1
  7. metadata +2 -195
  8. data/smoke-test/README.md +0 -58
  9. data/smoke-test/bundler/Gemfile +0 -9
  10. data/smoke-test/bundler/Gemfile.lock +0 -47
  11. data/smoke-test/bundler/dependabot-all-updates-test-staging.gemspec +0 -10
  12. data/smoke-test/cargo/Cargo.lock +0 -90
  13. data/smoke-test/cargo/Cargo.toml +0 -8
  14. data/smoke-test/composer/composer.json +0 -5
  15. data/smoke-test/composer/composer.lock +0 -72
  16. data/smoke-test/composer/vendor/autoload.php +0 -7
  17. data/smoke-test/composer/vendor/composer/ClassLoader.php +0 -445
  18. data/smoke-test/composer/vendor/composer/LICENSE +0 -21
  19. data/smoke-test/composer/vendor/composer/autoload_classmap.php +0 -13
  20. data/smoke-test/composer/vendor/composer/autoload_namespaces.php +0 -9
  21. data/smoke-test/composer/vendor/composer/autoload_psr4.php +0 -9
  22. data/smoke-test/composer/vendor/composer/autoload_real.php +0 -55
  23. data/smoke-test/composer/vendor/composer/autoload_static.php +0 -23
  24. data/smoke-test/composer/vendor/composer/installed.json +0 -57
  25. data/smoke-test/composer/vendor/phpmailer/phpmailer/.gitignore +0 -3
  26. data/smoke-test/composer/vendor/phpmailer/phpmailer/LICENSE +0 -504
  27. data/smoke-test/composer/vendor/phpmailer/phpmailer/README.md +0 -112
  28. data/smoke-test/composer/vendor/phpmailer/phpmailer/changelog.md +0 -530
  29. data/smoke-test/composer/vendor/phpmailer/phpmailer/class.phpmailer.php +0 -2758
  30. data/smoke-test/composer/vendor/phpmailer/phpmailer/class.pop3.php +0 -417
  31. data/smoke-test/composer/vendor/phpmailer/phpmailer/class.smtp.php +0 -1075
  32. data/smoke-test/composer/vendor/phpmailer/phpmailer/composer.json +0 -32
  33. data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/Callback_function_notes.txt +0 -17
  34. data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/DomainKeys_notes.txt +0 -55
  35. data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/Note_for_SMTP_debugging.txt +0 -23
  36. data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/extending.html +0 -148
  37. data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/faq.html +0 -67
  38. data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/generatedocs.sh +0 -4
  39. data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/pop3_article.txt +0 -39
  40. data/smoke-test/composer/vendor/phpmailer/phpmailer/docs/use_gmail.txt +0 -44
  41. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/contents.html +0 -20
  42. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/images/phpmailer.gif +0 -0
  43. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/images/phpmailer_mini.gif +0 -0
  44. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/index.html +0 -50
  45. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_db_smtp_basic.php +0 -58
  46. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_mail_advanced.php +0 -30
  47. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_mail_basic.php +0 -41
  48. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_pop_before_smtp_advanced.php +0 -39
  49. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_pop_before_smtp_basic.php +0 -49
  50. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_sendmail_advanced.php +0 -33
  51. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_sendmail_basic.php +0 -43
  52. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_smtp_advanced.php +0 -42
  53. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_smtp_advanced_no_auth.php +0 -36
  54. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_smtp_basic.php +0 -58
  55. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_smtp_basic_no_auth.php +0 -53
  56. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_smtp_gmail_advanced.php +0 -42
  57. data/smoke-test/composer/vendor/phpmailer/phpmailer/examples/test_smtp_gmail_basic.php +0 -59
  58. data/smoke-test/composer/vendor/phpmailer/phpmailer/extras/class.html2text.inc +0 -489
  59. data/smoke-test/composer/vendor/phpmailer/phpmailer/extras/htmlfilter.php +0 -861
  60. data/smoke-test/composer/vendor/phpmailer/phpmailer/extras/ntlm_sasl_client.php +0 -185
  61. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-ar.php +0 -26
  62. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-br.php +0 -25
  63. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-ca.php +0 -25
  64. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-ch.php +0 -25
  65. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-cz.php +0 -24
  66. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-de.php +0 -24
  67. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-dk.php +0 -25
  68. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-es.php +0 -25
  69. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-et.php +0 -25
  70. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-fi.php +0 -26
  71. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-fo.php +0 -26
  72. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-fr.php +0 -24
  73. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-hu.php +0 -24
  74. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-it.php +0 -26
  75. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-ja.php +0 -25
  76. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-nl.php +0 -24
  77. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-no.php +0 -24
  78. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-pl.php +0 -24
  79. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-ro.php +0 -26
  80. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-ru.php +0 -24
  81. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-se.php +0 -25
  82. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-sk.php +0 -25
  83. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-tr.php +0 -26
  84. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-zh.php +0 -25
  85. data/smoke-test/composer/vendor/phpmailer/phpmailer/language/phpmailer.lang-zh_cn.php +0 -25
  86. data/smoke-test/composer/vendor/phpmailer/phpmailer/test/contents.html +0 -10
  87. data/smoke-test/composer/vendor/phpmailer/phpmailer/test/phpmailerTest.php +0 -1084
  88. data/smoke-test/composer/vendor/phpmailer/phpmailer/test/test.png +0 -0
  89. data/smoke-test/composer/vendor/phpmailer/phpmailer/test/test_callback.php +0 -84
  90. data/smoke-test/composer/vendor/phpmailer/phpmailer/test/testemail.php +0 -48
  91. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/LGPLv3.txt +0 -165
  92. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/contents.html +0 -14
  93. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/images/aikido.gif +0 -0
  94. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/images/bkgrnd.gif +0 -0
  95. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/images/phpmailer.gif +0 -0
  96. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/index.php +0 -427
  97. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/clipboard.swf +0 -0
  98. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushBash.js +0 -59
  99. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushCSharp.js +0 -64
  100. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushCpp.js +0 -99
  101. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushCss.js +0 -93
  102. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushDelphi.js +0 -57
  103. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushDiff.js +0 -43
  104. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushGroovy.js +0 -69
  105. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushJScript.js +0 -51
  106. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushJava.js +0 -55
  107. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushPerl.js +0 -74
  108. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushPhp.js +0 -91
  109. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushPlain.js +0 -35
  110. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushPython.js +0 -56
  111. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushRuby.js +0 -57
  112. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushScala.js +0 -53
  113. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushSql.js +0 -68
  114. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushVb.js +0 -58
  115. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shBrushXml.js +0 -71
  116. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shCore.js +0 -30
  117. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/scripts/shLegacy.js +0 -30
  118. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/src/shCore.js +0 -1949
  119. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/src/shLegacy.js +0 -172
  120. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/help.png +0 -0
  121. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/magnifier.png +0 -0
  122. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/page_white_code.png +0 -0
  123. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/page_white_copy.png +0 -0
  124. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/printer.png +0 -0
  125. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shCore.css +0 -321
  126. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shThemeDefault.css +0 -191
  127. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shThemeDjango.css +0 -193
  128. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shThemeEmacs.css +0 -192
  129. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shThemeFadeToGrey.css +0 -193
  130. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shThemeMidnight.css +0 -192
  131. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/shThemeRDark.css +0 -192
  132. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/styles/wrapping.png +0 -0
  133. data/smoke-test/composer/vendor/phpmailer/phpmailer/test_script/test.html +0 -46
  134. data/smoke-test/dependabot-file/no-config/.github/TARGET.yaml +0 -14
  135. data/smoke-test/dependabot-file/no-config/bundler/Gemfile +0 -9
  136. data/smoke-test/dependabot-file/no-config/bundler/Gemfile.lock +0 -47
  137. data/smoke-test/dependabot-file/no-config/bundler/dependabot-all-updates-test-staging.gemspec +0 -10
  138. data/smoke-test/dependabot-file/no-config/cargo/Cargo.lock +0 -90
  139. data/smoke-test/dependabot-file/no-config/cargo/Cargo.toml +0 -8
  140. data/smoke-test/dependabot-file/no-config/composer/composer.json +0 -5
  141. data/smoke-test/dependabot-file/no-config/composer/composer.lock +0 -72
  142. data/smoke-test/dependabot-file/over-config/.github/TARGET.yaml +0 -17
  143. data/smoke-test/dependabot-file/over-config/.github/dependabot.yaml +0 -12
  144. data/smoke-test/dependabot-file/over-config/bundler/Gemfile +0 -9
  145. data/smoke-test/dependabot-file/over-config/bundler/Gemfile.lock +0 -47
  146. data/smoke-test/dependabot-file/over-config/bundler/dependabot-all-updates-test-staging.gemspec +0 -10
  147. data/smoke-test/dependabot-file/over-config/cargo/Cargo.lock +0 -90
  148. data/smoke-test/dependabot-file/over-config/cargo/Cargo.toml +0 -8
  149. data/smoke-test/dependabot-file/over-config/composer/composer.json +0 -5
  150. data/smoke-test/dependabot-file/over-config/composer/composer.lock +0 -72
  151. data/smoke-test/dependabot-file/overer-config/.github/TARGET.yaml +0 -19
  152. data/smoke-test/dependabot-file/overer-config/.github/dependabot.yaml +0 -12
  153. data/smoke-test/dependabot-file/overer-config/bundler/Gemfile +0 -9
  154. data/smoke-test/dependabot-file/overer-config/bundler/Gemfile.lock +0 -47
  155. data/smoke-test/dependabot-file/overer-config/bundler/dependabot-all-updates-test-staging.gemspec +0 -10
  156. data/smoke-test/dependabot-file/overer-config/cargo/Cargo.lock +0 -90
  157. data/smoke-test/dependabot-file/overer-config/cargo/Cargo.toml +0 -8
  158. data/smoke-test/dependabot-file/overer-config/composer/composer.json +0 -5
  159. data/smoke-test/dependabot-file/overer-config/composer/composer.lock +0 -72
  160. data/smoke-test/dependabot-file/partial-config/.github/TARGET.yaml +0 -17
  161. data/smoke-test/dependabot-file/partial-config/.github/dependabot.yaml +0 -7
  162. data/smoke-test/dependabot-file/partial-config/bundler/Gemfile +0 -9
  163. data/smoke-test/dependabot-file/partial-config/bundler/Gemfile.lock +0 -47
  164. data/smoke-test/dependabot-file/partial-config/bundler/dependabot-all-updates-test-staging.gemspec +0 -10
  165. data/smoke-test/dependabot-file/partial-config/cargo/Cargo.lock +0 -90
  166. data/smoke-test/dependabot-file/partial-config/cargo/Cargo.toml +0 -8
  167. data/smoke-test/dependabot-file/partial-config/composer/composer.json +0 -5
  168. data/smoke-test/dependabot-file/partial-config/composer/composer.lock +0 -72
  169. data/smoke-test/docker/Dockerfile +0 -19
  170. data/smoke-test/elm/elm-package.json +0 -15
  171. data/smoke-test/elm/elm.json +0 -31
  172. data/smoke-test/github-actions/both/.github/workflows/this.yaml +0 -11
  173. data/smoke-test/github-actions/both/yaml/action.yml +0 -13
  174. data/smoke-test/github-actions/invalid/invalid_file.yaml +0 -0
  175. data/smoke-test/github-actions/workflow/.github/workflows/this.yaml +0 -11
  176. data/smoke-test/github-actions/yaml/action.yml +0 -13
  177. data/smoke-test/gitsubmodule/.gitmodules +0 -4
  178. data/smoke-test/gomod/go.mod +0 -16
  179. data/smoke-test/gomod/go.sum +0 -18
  180. data/smoke-test/gomod/gomain.go +0 -14
  181. data/smoke-test/gradle/.gitignore +0 -1
  182. data/smoke-test/gradle/build.gradle +0 -65
  183. data/smoke-test/maven/pom.xml +0 -65
  184. data/smoke-test/mix/mix.exs +0 -24
  185. data/smoke-test/mix/mix.lock +0 -5
  186. data/smoke-test/npm/package-lock.json +0 -166
  187. data/smoke-test/npm/package.json +0 -22
  188. data/smoke-test/npm/removed/package-lock.json +0 -44
  189. data/smoke-test/npm/removed/package.json +0 -15
  190. data/smoke-test/nuget/project.csproj +0 -14
  191. data/smoke-test/pip/pip/requirements.txt +0 -5
  192. data/smoke-test/pip/pip-compile/requirements.in +0 -2
  193. data/smoke-test/pip/pip-compile/requirements.txt +0 -16
  194. data/smoke-test/pip/pipenv/Pipfile +0 -13
  195. data/smoke-test/pip/pipenv/Pipfile.lock +0 -86
  196. data/smoke-test/pip/poetry/poetry.lock +0 -33
  197. data/smoke-test/pip/poetry/pyproject.toml +0 -18
  198. data/smoke-test/pub/pubspec.lock +0 -40
  199. data/smoke-test/pub/pubspec.yaml +0 -10
  200. data/smoke-test/terraform/main.tf +0 -143
@@ -1,2758 +0,0 @@
1
- <?php
2
- /*~ class.phpmailer.php
3
- .---------------------------------------------------------------------------.
4
- | Software: PHPMailer - PHP email class |
5
- | Version: 5.2.2 |
6
- | Site: https://code.google.com/a/apache-extras.org/p/phpmailer/ |
7
- | ------------------------------------------------------------------------- |
8
- | Admin: Jim Jagielski (project admininistrator) |
9
- | Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net |
10
- | : Marcus Bointon (coolbru) phpmailer@synchromedia.co.uk |
11
- | : Jim Jagielski (jimjag) jimjag@gmail.com |
12
- | Founder: Brent R. Matzelle (original founder) |
13
- | Copyright (c) 2010-2012, Jim Jagielski. All Rights Reserved. |
14
- | Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. |
15
- | Copyright (c) 2001-2003, Brent R. Matzelle |
16
- | ------------------------------------------------------------------------- |
17
- | License: Distributed under the Lesser General Public License (LGPL) |
18
- | http://www.gnu.org/copyleft/lesser.html |
19
- | This program is distributed in the hope that it will be useful - WITHOUT |
20
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
21
- | FITNESS FOR A PARTICULAR PURPOSE. |
22
- '---------------------------------------------------------------------------'
23
- */
24
-
25
- /**
26
- * PHPMailer - PHP email creation and transport class
27
- * NOTE: Requires PHP version 5 or later
28
- * @package PHPMailer
29
- * @author Andy Prevost
30
- * @author Marcus Bointon
31
- * @author Jim Jagielski
32
- * @copyright 2010 - 2012 Jim Jagielski
33
- * @copyright 2004 - 2009 Andy Prevost
34
- * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
35
- */
36
-
37
- if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
38
-
39
- /**
40
- * PHP email creation and transport class
41
- * @package PHPMailer
42
- */
43
- class PHPMailer {
44
-
45
- /////////////////////////////////////////////////
46
- // PROPERTIES, PUBLIC
47
- /////////////////////////////////////////////////
48
-
49
- /**
50
- * Email priority (1 = High, 3 = Normal, 5 = low).
51
- * @var int
52
- */
53
- public $Priority = 3;
54
-
55
- /**
56
- * Sets the CharSet of the message.
57
- * @var string
58
- */
59
- public $CharSet = 'iso-8859-1';
60
-
61
- /**
62
- * Sets the Content-type of the message.
63
- * @var string
64
- */
65
- public $ContentType = 'text/plain';
66
-
67
- /**
68
- * Sets the Encoding of the message. Options for this are
69
- * "8bit", "7bit", "binary", "base64", and "quoted-printable".
70
- * @var string
71
- */
72
- public $Encoding = '8bit';
73
-
74
- /**
75
- * Holds the most recent mailer error message.
76
- * @var string
77
- */
78
- public $ErrorInfo = '';
79
-
80
- /**
81
- * Sets the From email address for the message.
82
- * @var string
83
- */
84
- public $From = 'root@localhost';
85
-
86
- /**
87
- * Sets the From name of the message.
88
- * @var string
89
- */
90
- public $FromName = 'Root User';
91
-
92
- /**
93
- * Sets the Sender email (Return-Path) of the message. If not empty,
94
- * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
95
- * @var string
96
- */
97
- public $Sender = '';
98
-
99
- /**
100
- * Sets the Return-Path of the message. If empty, it will
101
- * be set to either From or Sender.
102
- * @var string
103
- */
104
- public $ReturnPath = '';
105
-
106
- /**
107
- * Sets the Subject of the message.
108
- * @var string
109
- */
110
- public $Subject = '';
111
-
112
- /**
113
- * Sets the Body of the message. This can be either an HTML or text body.
114
- * If HTML then run IsHTML(true).
115
- * @var string
116
- */
117
- public $Body = '';
118
-
119
- /**
120
- * Sets the text-only body of the message. This automatically sets the
121
- * email to multipart/alternative. This body can be read by mail
122
- * clients that do not have HTML email capability such as mutt. Clients
123
- * that can read HTML will view the normal Body.
124
- * @var string
125
- */
126
- public $AltBody = '';
127
-
128
- /**
129
- * Stores the complete compiled MIME message body.
130
- * @var string
131
- * @access protected
132
- */
133
- protected $MIMEBody = '';
134
-
135
- /**
136
- * Stores the complete compiled MIME message headers.
137
- * @var string
138
- * @access protected
139
- */
140
- protected $MIMEHeader = '';
141
-
142
- /**
143
- * Stores the extra header list which CreateHeader() doesn't fold in
144
- * @var string
145
- * @access protected
146
- */
147
- protected $mailHeader = '';
148
-
149
- /**
150
- * Sets word wrapping on the body of the message to a given number of
151
- * characters.
152
- * @var int
153
- */
154
- public $WordWrap = 0;
155
-
156
- /**
157
- * Method to send mail: ("mail", "sendmail", or "smtp").
158
- * @var string
159
- */
160
- public $Mailer = 'mail';
161
-
162
- /**
163
- * Sets the path of the sendmail program.
164
- * @var string
165
- */
166
- public $Sendmail = '/usr/sbin/sendmail';
167
-
168
- /**
169
- * Determine if mail() uses a fully sendmail compatible MTA that
170
- * supports sendmail's "-oi -f" options
171
- * @var boolean
172
- */
173
- public $UseSendmailOptions = true;
174
-
175
- /**
176
- * Path to PHPMailer plugins. Useful if the SMTP class
177
- * is in a different directory than the PHP include path.
178
- * @var string
179
- */
180
- public $PluginDir = '';
181
-
182
- /**
183
- * Sets the email address that a reading confirmation will be sent.
184
- * @var string
185
- */
186
- public $ConfirmReadingTo = '';
187
-
188
- /**
189
- * Sets the hostname to use in Message-Id and Received headers
190
- * and as default HELO string. If empty, the value returned
191
- * by SERVER_NAME is used or 'localhost.localdomain'.
192
- * @var string
193
- */
194
- public $Hostname = '';
195
-
196
- /**
197
- * Sets the message ID to be used in the Message-Id header.
198
- * If empty, a unique id will be generated.
199
- * @var string
200
- */
201
- public $MessageID = '';
202
-
203
- /**
204
- * Sets the message Date to be used in the Date header.
205
- * If empty, the current date will be added.
206
- * @var string
207
- */
208
- public $MessageDate = '';
209
-
210
- /////////////////////////////////////////////////
211
- // PROPERTIES FOR SMTP
212
- /////////////////////////////////////////////////
213
-
214
- /**
215
- * Sets the SMTP hosts.
216
- *
217
- * All hosts must be separated by a
218
- * semicolon. You can also specify a different port
219
- * for each host by using this format: [hostname:port]
220
- * (e.g. "smtp1.example.com:25;smtp2.example.com").
221
- * Hosts will be tried in order.
222
- * @var string
223
- */
224
- public $Host = 'localhost';
225
-
226
- /**
227
- * Sets the default SMTP server port.
228
- * @var int
229
- */
230
- public $Port = 25;
231
-
232
- /**
233
- * Sets the SMTP HELO of the message (Default is $Hostname).
234
- * @var string
235
- */
236
- public $Helo = '';
237
-
238
- /**
239
- * Sets connection prefix. Options are "", "ssl" or "tls"
240
- * @var string
241
- */
242
- public $SMTPSecure = '';
243
-
244
- /**
245
- * Sets SMTP authentication. Utilizes the Username and Password variables.
246
- * @var bool
247
- */
248
- public $SMTPAuth = false;
249
-
250
- /**
251
- * Sets SMTP username.
252
- * @var string
253
- */
254
- public $Username = '';
255
-
256
- /**
257
- * Sets SMTP password.
258
- * @var string
259
- */
260
- public $Password = '';
261
-
262
- /**
263
- * Sets SMTP auth type. Options are LOGIN | PLAIN | NTLM | CRAM-MD5 (default LOGIN)
264
- * @var string
265
- */
266
- public $AuthType = '';
267
-
268
- /**
269
- * Sets SMTP realm.
270
- * @var string
271
- */
272
- public $Realm = '';
273
-
274
- /**
275
- * Sets SMTP workstation.
276
- * @var string
277
- */
278
- public $Workstation = '';
279
-
280
- /**
281
- * Sets the SMTP server timeout in seconds.
282
- * This function will not work with the win32 version.
283
- * @var int
284
- */
285
- public $Timeout = 10;
286
-
287
- /**
288
- * Sets SMTP class debugging on or off.
289
- * @var bool
290
- */
291
- public $SMTPDebug = false;
292
-
293
- /**
294
- * Sets the function/method to use for debugging output.
295
- * Right now we only honor "echo" or "error_log"
296
- * @var string
297
- */
298
- public $Debugoutput = "echo";
299
-
300
- /**
301
- * Prevents the SMTP connection from being closed after each mail
302
- * sending. If this is set to true then to close the connection
303
- * requires an explicit call to SmtpClose().
304
- * @var bool
305
- */
306
- public $SMTPKeepAlive = false;
307
-
308
- /**
309
- * Provides the ability to have the TO field process individual
310
- * emails, instead of sending to entire TO addresses
311
- * @var bool
312
- */
313
- public $SingleTo = false;
314
-
315
- /**
316
- * If SingleTo is true, this provides the array to hold the email addresses
317
- * @var bool
318
- */
319
- public $SingleToArray = array();
320
-
321
- /**
322
- * Provides the ability to change the generic line ending
323
- * NOTE: The default remains '\n'. We force CRLF where we KNOW
324
- * it must be used via self::CRLF
325
- * @var string
326
- */
327
- public $LE = "\n";
328
-
329
- /**
330
- * Used with DKIM Signing
331
- * required parameter if DKIM is enabled
332
- *
333
- * domain selector example domainkey
334
- * @var string
335
- */
336
- public $DKIM_selector = '';
337
-
338
- /**
339
- * Used with DKIM Signing
340
- * required if DKIM is enabled, in format of email address 'you@yourdomain.com' typically used as the source of the email
341
- * @var string
342
- */
343
- public $DKIM_identity = '';
344
-
345
- /**
346
- * Used with DKIM Signing
347
- * optional parameter if your private key requires a passphras
348
- * @var string
349
- */
350
- public $DKIM_passphrase = '';
351
-
352
- /**
353
- * Used with DKIM Singing
354
- * required if DKIM is enabled, in format of email address 'domain.com'
355
- * @var string
356
- */
357
- public $DKIM_domain = '';
358
-
359
- /**
360
- * Used with DKIM Signing
361
- * required if DKIM is enabled, path to private key file
362
- * @var string
363
- */
364
- public $DKIM_private = '';
365
-
366
- /**
367
- * Callback Action function name.
368
- * The function that handles the result of the send email action.
369
- * It is called out by Send() for each email sent.
370
- *
371
- * Value can be:
372
- * - 'function_name' for function names
373
- * - 'Class::Method' for static method calls
374
- * - array($object, 'Method') for calling methods on $object
375
- * See http://php.net/is_callable manual page for more details.
376
- *
377
- * Parameters:
378
- * bool $result result of the send action
379
- * string $to email address of the recipient
380
- * string $cc cc email addresses
381
- * string $bcc bcc email addresses
382
- * string $subject the subject
383
- * string $body the email body
384
- * string $from email address of sender
385
- * @var string
386
- */
387
- public $action_function = ''; //'callbackAction';
388
-
389
- /**
390
- * Sets the PHPMailer Version number
391
- * @var string
392
- */
393
- public $Version = '5.2.2';
394
-
395
- /**
396
- * What to use in the X-Mailer header
397
- * @var string NULL for default, whitespace for None, or actual string to use
398
- */
399
- public $XMailer = '';
400
-
401
- /////////////////////////////////////////////////
402
- // PROPERTIES, PRIVATE AND PROTECTED
403
- /////////////////////////////////////////////////
404
-
405
- /**
406
- * @var SMTP An instance of the SMTP sender class
407
- * @access protected
408
- */
409
- protected $smtp = null;
410
- /**
411
- * @var array An array of 'to' addresses
412
- * @access protected
413
- */
414
- protected $to = array();
415
- /**
416
- * @var array An array of 'cc' addresses
417
- * @access protected
418
- */
419
- protected $cc = array();
420
- /**
421
- * @var array An array of 'bcc' addresses
422
- * @access protected
423
- */
424
- protected $bcc = array();
425
- /**
426
- * @var array An array of reply-to name and address
427
- * @access protected
428
- */
429
- protected $ReplyTo = array();
430
- /**
431
- * @var array An array of all kinds of addresses: to, cc, bcc, replyto
432
- * @access protected
433
- */
434
- protected $all_recipients = array();
435
- /**
436
- * @var array An array of attachments
437
- * @access protected
438
- */
439
- protected $attachment = array();
440
- /**
441
- * @var array An array of custom headers
442
- * @access protected
443
- */
444
- protected $CustomHeader = array();
445
- /**
446
- * @var string The message's MIME type
447
- * @access protected
448
- */
449
- protected $message_type = '';
450
- /**
451
- * @var array An array of MIME boundary strings
452
- * @access protected
453
- */
454
- protected $boundary = array();
455
- /**
456
- * @var array An array of available languages
457
- * @access protected
458
- */
459
- protected $language = array();
460
- /**
461
- * @var integer The number of errors encountered
462
- * @access protected
463
- */
464
- protected $error_count = 0;
465
- /**
466
- * @var string The filename of a DKIM certificate file
467
- * @access protected
468
- */
469
- protected $sign_cert_file = '';
470
- /**
471
- * @var string The filename of a DKIM key file
472
- * @access protected
473
- */
474
- protected $sign_key_file = '';
475
- /**
476
- * @var string The password of a DKIM key
477
- * @access protected
478
- */
479
- protected $sign_key_pass = '';
480
- /**
481
- * @var boolean Whether to throw exceptions for errors
482
- * @access protected
483
- */
484
- protected $exceptions = false;
485
-
486
- /////////////////////////////////////////////////
487
- // CONSTANTS
488
- /////////////////////////////////////////////////
489
-
490
- const STOP_MESSAGE = 0; // message only, continue processing
491
- const STOP_CONTINUE = 1; // message?, likely ok to continue processing
492
- const STOP_CRITICAL = 2; // message, plus full stop, critical error reached
493
- const CRLF = "\r\n"; // SMTP RFC specified EOL
494
-
495
- /////////////////////////////////////////////////
496
- // METHODS, VARIABLES
497
- /////////////////////////////////////////////////
498
-
499
- /**
500
- * Calls actual mail() function, but in a safe_mode aware fashion
501
- * Also, unless sendmail_path points to sendmail (or something that
502
- * claims to be sendmail), don't pass params (not a perfect fix,
503
- * but it will do)
504
- * @param string $to To
505
- * @param string $subject Subject
506
- * @param string $body Message Body
507
- * @param string $header Additional Header(s)
508
- * @param string $params Params
509
- * @access private
510
- * @return bool
511
- */
512
- private function mail_passthru($to, $subject, $body, $header, $params) {
513
- if ( ini_get('safe_mode') || !($this->UseSendmailOptions) ) {
514
- $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($subject)), $body, $header);
515
- } else {
516
- $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($subject)), $body, $header, $params);
517
- }
518
- return $rt;
519
- }
520
-
521
- /**
522
- * Outputs debugging info via user-defined method
523
- * @param string $str
524
- */
525
- private function edebug($str) {
526
- if ($this->Debugoutput == "error_log") {
527
- error_log($str);
528
- } else {
529
- echo $str;
530
- }
531
- }
532
-
533
- /**
534
- * Constructor
535
- * @param boolean $exceptions Should we throw external exceptions?
536
- */
537
- public function __construct($exceptions = false) {
538
- $this->exceptions = ($exceptions == true);
539
- }
540
-
541
- /**
542
- * Sets message type to HTML.
543
- * @param bool $ishtml
544
- * @return void
545
- */
546
- public function IsHTML($ishtml = true) {
547
- if ($ishtml) {
548
- $this->ContentType = 'text/html';
549
- } else {
550
- $this->ContentType = 'text/plain';
551
- }
552
- }
553
-
554
- /**
555
- * Sets Mailer to send message using SMTP.
556
- * @return void
557
- * @deprecated
558
- */
559
- public function IsSMTP() {
560
- $this->Mailer = 'smtp';
561
- }
562
-
563
- /**
564
- * Sets Mailer to send message using PHP mail() function.
565
- * @return void
566
- * @deprecated
567
- */
568
- public function IsMail() {
569
- $this->Mailer = 'mail';
570
- }
571
-
572
- /**
573
- * Sets Mailer to send message using the $Sendmail program.
574
- * @return void
575
- * @deprecated
576
- */
577
- public function IsSendmail() {
578
- if (!stristr(ini_get('sendmail_path'), 'sendmail')) {
579
- $this->Sendmail = '/var/qmail/bin/sendmail';
580
- }
581
- $this->Mailer = 'sendmail';
582
- }
583
-
584
- /**
585
- * Sets Mailer to send message using the qmail MTA.
586
- * @return void
587
- * @deprecated
588
- */
589
- public function IsQmail() {
590
- if (stristr(ini_get('sendmail_path'), 'qmail')) {
591
- $this->Sendmail = '/var/qmail/bin/sendmail';
592
- }
593
- $this->Mailer = 'sendmail';
594
- }
595
-
596
- /////////////////////////////////////////////////
597
- // METHODS, RECIPIENTS
598
- /////////////////////////////////////////////////
599
-
600
- /**
601
- * Adds a "To" address.
602
- * @param string $address
603
- * @param string $name
604
- * @return boolean true on success, false if address already used
605
- */
606
- public function AddAddress($address, $name = '') {
607
- return $this->AddAnAddress('to', $address, $name);
608
- }
609
-
610
- /**
611
- * Adds a "Cc" address.
612
- * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
613
- * @param string $address
614
- * @param string $name
615
- * @return boolean true on success, false if address already used
616
- */
617
- public function AddCC($address, $name = '') {
618
- return $this->AddAnAddress('cc', $address, $name);
619
- }
620
-
621
- /**
622
- * Adds a "Bcc" address.
623
- * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
624
- * @param string $address
625
- * @param string $name
626
- * @return boolean true on success, false if address already used
627
- */
628
- public function AddBCC($address, $name = '') {
629
- return $this->AddAnAddress('bcc', $address, $name);
630
- }
631
-
632
- /**
633
- * Adds a "Reply-to" address.
634
- * @param string $address
635
- * @param string $name
636
- * @return boolean
637
- */
638
- public function AddReplyTo($address, $name = '') {
639
- return $this->AddAnAddress('Reply-To', $address, $name);
640
- }
641
-
642
- /**
643
- * Adds an address to one of the recipient arrays
644
- * Addresses that have been added already return false, but do not throw exceptions
645
- * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo'
646
- * @param string $address The email address to send to
647
- * @param string $name
648
- * @throws phpmailerException
649
- * @return boolean true on success, false if address already used or invalid in some way
650
- * @access protected
651
- */
652
- protected function AddAnAddress($kind, $address, $name = '') {
653
- if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) {
654
- $this->SetError($this->Lang('Invalid recipient array').': '.$kind);
655
- if ($this->exceptions) {
656
- throw new phpmailerException('Invalid recipient array: ' . $kind);
657
- }
658
- if ($this->SMTPDebug) {
659
- $this->edebug($this->Lang('Invalid recipient array').': '.$kind);
660
- }
661
- return false;
662
- }
663
- $address = trim($address);
664
- $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
665
- if (!$this->ValidateAddress($address)) {
666
- $this->SetError($this->Lang('invalid_address').': '. $address);
667
- if ($this->exceptions) {
668
- throw new phpmailerException($this->Lang('invalid_address').': '.$address);
669
- }
670
- if ($this->SMTPDebug) {
671
- $this->edebug($this->Lang('invalid_address').': '.$address);
672
- }
673
- return false;
674
- }
675
- if ($kind != 'Reply-To') {
676
- if (!isset($this->all_recipients[strtolower($address)])) {
677
- array_push($this->$kind, array($address, $name));
678
- $this->all_recipients[strtolower($address)] = true;
679
- return true;
680
- }
681
- } else {
682
- if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
683
- $this->ReplyTo[strtolower($address)] = array($address, $name);
684
- return true;
685
- }
686
- }
687
- return false;
688
- }
689
-
690
- /**
691
- * Set the From and FromName properties
692
- * @param string $address
693
- * @param string $name
694
- * @param int $auto Also set Reply-To and Sender
695
- * @throws phpmailerException
696
- * @return boolean
697
- */
698
- public function SetFrom($address, $name = '', $auto = 1) {
699
- $address = trim($address);
700
- $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
701
- if (!$this->ValidateAddress($address)) {
702
- $this->SetError($this->Lang('invalid_address').': '. $address);
703
- if ($this->exceptions) {
704
- throw new phpmailerException($this->Lang('invalid_address').': '.$address);
705
- }
706
- if ($this->SMTPDebug) {
707
- $this->edebug($this->Lang('invalid_address').': '.$address);
708
- }
709
- return false;
710
- }
711
- $this->From = $address;
712
- $this->FromName = $name;
713
- if ($auto) {
714
- if (empty($this->ReplyTo)) {
715
- $this->AddAnAddress('Reply-To', $address, $name);
716
- }
717
- if (empty($this->Sender)) {
718
- $this->Sender = $address;
719
- }
720
- }
721
- return true;
722
- }
723
-
724
- /**
725
- * Check that a string looks roughly like an email address should
726
- * Static so it can be used without instantiation, public so people can overload
727
- * Conforms to RFC5322: Uses *correct* regex on which FILTER_VALIDATE_EMAIL is
728
- * based; So why not use FILTER_VALIDATE_EMAIL? Because it was broken to
729
- * not allow a@b type valid addresses :(
730
- * @link http://squiloople.com/2009/12/20/email-address-validation/
731
- * @copyright regex Copyright Michael Rushton 2009-10 | http://squiloople.com/ | Feel free to use and redistribute this code. But please keep this copyright notice.
732
- * @param string $address The email address to check
733
- * @return boolean
734
- * @static
735
- * @access public
736
- */
737
- public static function ValidateAddress($address) {
738
- 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][:\]]){7,})((?6)(?>:(?6)){0,5})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:|(?!(?:.*[a-f0-9]:){5,})(?8)?::(?>((?6)(?>:(?6)){0,3}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', $address);
739
- }
740
-
741
- /////////////////////////////////////////////////
742
- // METHODS, MAIL SENDING
743
- /////////////////////////////////////////////////
744
-
745
- /**
746
- * Creates message and assigns Mailer. If the message is
747
- * not sent successfully then it returns false. Use the ErrorInfo
748
- * variable to view description of the error.
749
- * @throws phpmailerException
750
- * @return bool
751
- */
752
- public function Send() {
753
- try {
754
- if(!$this->PreSend()) return false;
755
- return $this->PostSend();
756
- } catch (phpmailerException $e) {
757
- $this->mailHeader = '';
758
- $this->SetError($e->getMessage());
759
- if ($this->exceptions) {
760
- throw $e;
761
- }
762
- return false;
763
- }
764
- }
765
-
766
- /**
767
- * Prep mail by constructing all message entities
768
- * @throws phpmailerException
769
- * @return bool
770
- */
771
- public function PreSend() {
772
- try {
773
- $this->mailHeader = "";
774
- if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
775
- throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL);
776
- }
777
-
778
- // Set whether the message is multipart/alternative
779
- if(!empty($this->AltBody)) {
780
- $this->ContentType = 'multipart/alternative';
781
- }
782
-
783
- $this->error_count = 0; // reset errors
784
- $this->SetMessageType();
785
- //Refuse to send an empty message
786
- if (empty($this->Body)) {
787
- throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL);
788
- }
789
-
790
- $this->MIMEHeader = $this->CreateHeader();
791
- $this->MIMEBody = $this->CreateBody();
792
-
793
- // To capture the complete message when using mail(), create
794
- // an extra header list which CreateHeader() doesn't fold in
795
- if ($this->Mailer == 'mail') {
796
- if (count($this->to) > 0) {
797
- $this->mailHeader .= $this->AddrAppend("To", $this->to);
798
- } else {
799
- $this->mailHeader .= $this->HeaderLine("To", "undisclosed-recipients:;");
800
- }
801
- $this->mailHeader .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader(trim($this->Subject))));
802
- // if(count($this->cc) > 0) {
803
- // $this->mailHeader .= $this->AddrAppend("Cc", $this->cc);
804
- // }
805
- }
806
-
807
- // digitally sign with DKIM if enabled
808
- if (!empty($this->DKIM_domain) && !empty($this->DKIM_private) && !empty($this->DKIM_selector) && !empty($this->DKIM_domain) && file_exists($this->DKIM_private)) {
809
- $header_dkim = $this->DKIM_Add($this->MIMEHeader, $this->EncodeHeader($this->SecureHeader($this->Subject)), $this->MIMEBody);
810
- $this->MIMEHeader = str_replace("\r\n", "\n", $header_dkim) . $this->MIMEHeader;
811
- }
812
-
813
- return true;
814
-
815
- } catch (phpmailerException $e) {
816
- $this->SetError($e->getMessage());
817
- if ($this->exceptions) {
818
- throw $e;
819
- }
820
- return false;
821
- }
822
- }
823
-
824
- /**
825
- * Actual Email transport function
826
- * Send the email via the selected mechanism
827
- * @throws phpmailerException
828
- * @return bool
829
- */
830
- public function PostSend() {
831
- try {
832
- // Choose the mailer and send through it
833
- switch($this->Mailer) {
834
- case 'sendmail':
835
- return $this->SendmailSend($this->MIMEHeader, $this->MIMEBody);
836
- case 'smtp':
837
- return $this->SmtpSend($this->MIMEHeader, $this->MIMEBody);
838
- case 'mail':
839
- return $this->MailSend($this->MIMEHeader, $this->MIMEBody);
840
- default:
841
- return $this->MailSend($this->MIMEHeader, $this->MIMEBody);
842
- }
843
- } catch (phpmailerException $e) {
844
- $this->SetError($e->getMessage());
845
- if ($this->exceptions) {
846
- throw $e;
847
- }
848
- if ($this->SMTPDebug) {
849
- $this->edebug($e->getMessage()."\n");
850
- }
851
- }
852
- return false;
853
- }
854
-
855
- /**
856
- * Sends mail using the $Sendmail program.
857
- * @param string $header The message headers
858
- * @param string $body The message body
859
- * @throws phpmailerException
860
- * @access protected
861
- * @return bool
862
- */
863
- protected function SendmailSend($header, $body) {
864
- if ($this->Sender != '') {
865
- $sendmail = sprintf("%s -oi -f%s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
866
- } else {
867
- $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
868
- }
869
- if ($this->SingleTo === true) {
870
- foreach ($this->SingleToArray as $val) {
871
- if(!@$mail = popen($sendmail, 'w')) {
872
- throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
873
- }
874
- fputs($mail, "To: " . $val . "\n");
875
- fputs($mail, $header);
876
- fputs($mail, $body);
877
- $result = pclose($mail);
878
- // implement call back function if it exists
879
- $isSent = ($result == 0) ? 1 : 0;
880
- $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
881
- if($result != 0) {
882
- throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
883
- }
884
- }
885
- } else {
886
- if(!@$mail = popen($sendmail, 'w')) {
887
- throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
888
- }
889
- fputs($mail, $header);
890
- fputs($mail, $body);
891
- $result = pclose($mail);
892
- // implement call back function if it exists
893
- $isSent = ($result == 0) ? 1 : 0;
894
- $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body);
895
- if($result != 0) {
896
- throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
897
- }
898
- }
899
- return true;
900
- }
901
-
902
- /**
903
- * Sends mail using the PHP mail() function.
904
- * @param string $header The message headers
905
- * @param string $body The message body
906
- * @throws phpmailerException
907
- * @access protected
908
- * @return bool
909
- */
910
- protected function MailSend($header, $body) {
911
- $toArr = array();
912
- foreach($this->to as $t) {
913
- $toArr[] = $this->AddrFormat($t);
914
- }
915
- $to = implode(', ', $toArr);
916
-
917
- if (empty($this->Sender)) {
918
- $params = "-oi ";
919
- } else {
920
- $params = sprintf("-oi -f%s", $this->Sender);
921
- }
922
- if ($this->Sender != '' and !ini_get('safe_mode')) {
923
- $old_from = ini_get('sendmail_from');
924
- ini_set('sendmail_from', $this->Sender);
925
- }
926
- $rt = false;
927
- if ($this->SingleTo === true && count($toArr) > 1) {
928
- foreach ($toArr as $val) {
929
- $rt = $this->mail_passthru($val, $this->Subject, $body, $header, $params);
930
- // implement call back function if it exists
931
- $isSent = ($rt == 1) ? 1 : 0;
932
- $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
933
- }
934
- } else {
935
- $rt = $this->mail_passthru($to, $this->Subject, $body, $header, $params);
936
- // implement call back function if it exists
937
- $isSent = ($rt == 1) ? 1 : 0;
938
- $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
939
- }
940
- if (isset($old_from)) {
941
- ini_set('sendmail_from', $old_from);
942
- }
943
- if(!$rt) {
944
- throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL);
945
- }
946
- return true;
947
- }
948
-
949
- /**
950
- * Sends mail via SMTP using PhpSMTP
951
- * Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
952
- * @param string $header The message headers
953
- * @param string $body The message body
954
- * @throws phpmailerException
955
- * @uses SMTP
956
- * @access protected
957
- * @return bool
958
- */
959
- protected function SmtpSend($header, $body) {
960
- require_once $this->PluginDir . 'class.smtp.php';
961
- $bad_rcpt = array();
962
-
963
- if(!$this->SmtpConnect()) {
964
- throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
965
- }
966
- $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
967
- if(!$this->smtp->Mail($smtp_from)) {
968
- throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
969
- }
970
-
971
- // Attempt to send attach all recipients
972
- foreach($this->to as $to) {
973
- if (!$this->smtp->Recipient($to[0])) {
974
- $bad_rcpt[] = $to[0];
975
- // implement call back function if it exists
976
- $isSent = 0;
977
- $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body);
978
- } else {
979
- // implement call back function if it exists
980
- $isSent = 1;
981
- $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body);
982
- }
983
- }
984
- foreach($this->cc as $cc) {
985
- if (!$this->smtp->Recipient($cc[0])) {
986
- $bad_rcpt[] = $cc[0];
987
- // implement call back function if it exists
988
- $isSent = 0;
989
- $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body);
990
- } else {
991
- // implement call back function if it exists
992
- $isSent = 1;
993
- $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body);
994
- }
995
- }
996
- foreach($this->bcc as $bcc) {
997
- if (!$this->smtp->Recipient($bcc[0])) {
998
- $bad_rcpt[] = $bcc[0];
999
- // implement call back function if it exists
1000
- $isSent = 0;
1001
- $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body);
1002
- } else {
1003
- // implement call back function if it exists
1004
- $isSent = 1;
1005
- $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body);
1006
- }
1007
- }
1008
-
1009
-
1010
- if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
1011
- $badaddresses = implode(', ', $bad_rcpt);
1012
- throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
1013
- }
1014
- if(!$this->smtp->Data($header . $body)) {
1015
- throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
1016
- }
1017
- if($this->SMTPKeepAlive == true) {
1018
- $this->smtp->Reset();
1019
- } else {
1020
- $this->smtp->Quit();
1021
- $this->smtp->Close();
1022
- }
1023
- return true;
1024
- }
1025
-
1026
- /**
1027
- * Initiates a connection to an SMTP server.
1028
- * Returns false if the operation failed.
1029
- * @uses SMTP
1030
- * @access public
1031
- * @throws phpmailerException
1032
- * @return bool
1033
- */
1034
- public function SmtpConnect() {
1035
- if(is_null($this->smtp)) {
1036
- $this->smtp = new SMTP;
1037
- }
1038
-
1039
- $this->smtp->Timeout = $this->Timeout;
1040
- $this->smtp->do_debug = $this->SMTPDebug;
1041
- $hosts = explode(';', $this->Host);
1042
- $index = 0;
1043
- $connection = $this->smtp->Connected();
1044
-
1045
- // Retry while there is no connection
1046
- try {
1047
- while($index < count($hosts) && !$connection) {
1048
- $hostinfo = array();
1049
- if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) {
1050
- $host = $hostinfo[1];
1051
- $port = $hostinfo[2];
1052
- } else {
1053
- $host = $hosts[$index];
1054
- $port = $this->Port;
1055
- }
1056
-
1057
- $tls = ($this->SMTPSecure == 'tls');
1058
- $ssl = ($this->SMTPSecure == 'ssl');
1059
-
1060
- if ($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) {
1061
-
1062
- $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname());
1063
- $this->smtp->Hello($hello);
1064
-
1065
- if ($tls) {
1066
- if (!$this->smtp->StartTLS()) {
1067
- throw new phpmailerException($this->Lang('tls'));
1068
- }
1069
-
1070
- //We must resend HELO after tls negotiation
1071
- $this->smtp->Hello($hello);
1072
- }
1073
-
1074
- $connection = true;
1075
- if ($this->SMTPAuth) {
1076
- if (!$this->smtp->Authenticate($this->Username, $this->Password, $this->AuthType, $this->Realm, $this->Workstation)) {
1077
- throw new phpmailerException($this->Lang('authenticate'));
1078
- }
1079
- }
1080
- }
1081
- $index++;
1082
- if (!$connection) {
1083
- throw new phpmailerException($this->Lang('connect_host'));
1084
- }
1085
- }
1086
- } catch (phpmailerException $e) {
1087
- $this->smtp->Reset();
1088
- if ($this->exceptions) {
1089
- throw $e;
1090
- }
1091
- }
1092
- return true;
1093
- }
1094
-
1095
- /**
1096
- * Closes the active SMTP session if one exists.
1097
- * @return void
1098
- */
1099
- public function SmtpClose() {
1100
- if ($this->smtp !== null) {
1101
- if($this->smtp->Connected()) {
1102
- $this->smtp->Quit();
1103
- $this->smtp->Close();
1104
- }
1105
- }
1106
- }
1107
-
1108
- /**
1109
- * Sets the language for all class error messages.
1110
- * Returns false if it cannot load the language file. The default language is English.
1111
- * @param string $langcode ISO 639-1 2-character language code (e.g. Portuguese: "br")
1112
- * @param string $lang_path Path to the language file directory
1113
- * @return bool
1114
- * @access public
1115
- */
1116
- function SetLanguage($langcode = 'en', $lang_path = 'language/') {
1117
- //Define full set of translatable strings
1118
- $PHPMAILER_LANG = array(
1119
- 'authenticate' => 'SMTP Error: Could not authenticate.',
1120
- 'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
1121
- 'data_not_accepted' => 'SMTP Error: Data not accepted.',
1122
- 'empty_message' => 'Message body empty',
1123
- 'encoding' => 'Unknown encoding: ',
1124
- 'execute' => 'Could not execute: ',
1125
- 'file_access' => 'Could not access file: ',
1126
- 'file_open' => 'File Error: Could not open file: ',
1127
- 'from_failed' => 'The following From address failed: ',
1128
- 'instantiate' => 'Could not instantiate mail function.',
1129
- 'invalid_address' => 'Invalid address',
1130
- 'mailer_not_supported' => ' mailer is not supported.',
1131
- 'provide_address' => 'You must provide at least one recipient email address.',
1132
- 'recipients_failed' => 'SMTP Error: The following recipients failed: ',
1133
- 'signing' => 'Signing Error: ',
1134
- 'smtp_connect_failed' => 'SMTP Connect() failed.',
1135
- 'smtp_error' => 'SMTP server error: ',
1136
- 'variable_set' => 'Cannot set or reset variable: '
1137
- );
1138
- //Overwrite language-specific strings. This way we'll never have missing translations - no more "language string failed to load"!
1139
- $l = true;
1140
- if ($langcode != 'en') { //There is no English translation file
1141
- $l = @include $lang_path.'phpmailer.lang-'.$langcode.'.php';
1142
- }
1143
- $this->language = $PHPMAILER_LANG;
1144
- return ($l == true); //Returns false if language not found
1145
- }
1146
-
1147
- /**
1148
- * Return the current array of language strings
1149
- * @return array
1150
- */
1151
- public function GetTranslations() {
1152
- return $this->language;
1153
- }
1154
-
1155
- /////////////////////////////////////////////////
1156
- // METHODS, MESSAGE CREATION
1157
- /////////////////////////////////////////////////
1158
-
1159
- /**
1160
- * Creates recipient headers.
1161
- * @access public
1162
- * @param string $type
1163
- * @param array $addr
1164
- * @return string
1165
- */
1166
- public function AddrAppend($type, $addr) {
1167
- $addr_str = $type . ': ';
1168
- $addresses = array();
1169
- foreach ($addr as $a) {
1170
- $addresses[] = $this->AddrFormat($a);
1171
- }
1172
- $addr_str .= implode(', ', $addresses);
1173
- $addr_str .= $this->LE;
1174
-
1175
- return $addr_str;
1176
- }
1177
-
1178
- /**
1179
- * Formats an address correctly.
1180
- * @access public
1181
- * @param string $addr
1182
- * @return string
1183
- */
1184
- public function AddrFormat($addr) {
1185
- if (empty($addr[1])) {
1186
- return $this->SecureHeader($addr[0]);
1187
- } else {
1188
- return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
1189
- }
1190
- }
1191
-
1192
- /**
1193
- * Wraps message for use with mailers that do not
1194
- * automatically perform wrapping and for quoted-printable.
1195
- * Original written by philippe.
1196
- * @param string $message The message to wrap
1197
- * @param integer $length The line length to wrap to
1198
- * @param boolean $qp_mode Whether to run in Quoted-Printable mode
1199
- * @access public
1200
- * @return string
1201
- */
1202
- public function WrapText($message, $length, $qp_mode = false) {
1203
- $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
1204
- // If utf-8 encoding is used, we will need to make sure we don't
1205
- // split multibyte characters when we wrap
1206
- $is_utf8 = (strtolower($this->CharSet) == "utf-8");
1207
- $lelen = strlen($this->LE);
1208
- $crlflen = strlen(self::CRLF);
1209
-
1210
- $message = $this->FixEOL($message);
1211
- if (substr($message, -$lelen) == $this->LE) {
1212
- $message = substr($message, 0, -$lelen);
1213
- }
1214
-
1215
- $line = explode($this->LE, $message); // Magic. We know FixEOL uses $LE
1216
- $message = '';
1217
- for ($i = 0 ;$i < count($line); $i++) {
1218
- $line_part = explode(' ', $line[$i]);
1219
- $buf = '';
1220
- for ($e = 0; $e<count($line_part); $e++) {
1221
- $word = $line_part[$e];
1222
- if ($qp_mode and (strlen($word) > $length)) {
1223
- $space_left = $length - strlen($buf) - $crlflen;
1224
- if ($e != 0) {
1225
- if ($space_left > 20) {
1226
- $len = $space_left;
1227
- if ($is_utf8) {
1228
- $len = $this->UTF8CharBoundary($word, $len);
1229
- } elseif (substr($word, $len - 1, 1) == "=") {
1230
- $len--;
1231
- } elseif (substr($word, $len - 2, 1) == "=") {
1232
- $len -= 2;
1233
- }
1234
- $part = substr($word, 0, $len);
1235
- $word = substr($word, $len);
1236
- $buf .= ' ' . $part;
1237
- $message .= $buf . sprintf("=%s", self::CRLF);
1238
- } else {
1239
- $message .= $buf . $soft_break;
1240
- }
1241
- $buf = '';
1242
- }
1243
- while (strlen($word) > 0) {
1244
- $len = $length;
1245
- if ($is_utf8) {
1246
- $len = $this->UTF8CharBoundary($word, $len);
1247
- } elseif (substr($word, $len - 1, 1) == "=") {
1248
- $len--;
1249
- } elseif (substr($word, $len - 2, 1) == "=") {
1250
- $len -= 2;
1251
- }
1252
- $part = substr($word, 0, $len);
1253
- $word = substr($word, $len);
1254
-
1255
- if (strlen($word) > 0) {
1256
- $message .= $part . sprintf("=%s", self::CRLF);
1257
- } else {
1258
- $buf = $part;
1259
- }
1260
- }
1261
- } else {
1262
- $buf_o = $buf;
1263
- $buf .= ($e == 0) ? $word : (' ' . $word);
1264
-
1265
- if (strlen($buf) > $length and $buf_o != '') {
1266
- $message .= $buf_o . $soft_break;
1267
- $buf = $word;
1268
- }
1269
- }
1270
- }
1271
- $message .= $buf . self::CRLF;
1272
- }
1273
-
1274
- return $message;
1275
- }
1276
-
1277
- /**
1278
- * Finds last character boundary prior to maxLength in a utf-8
1279
- * quoted (printable) encoded string.
1280
- * Original written by Colin Brown.
1281
- * @access public
1282
- * @param string $encodedText utf-8 QP text
1283
- * @param int $maxLength find last character boundary prior to this length
1284
- * @return int
1285
- */
1286
- public function UTF8CharBoundary($encodedText, $maxLength) {
1287
- $foundSplitPos = false;
1288
- $lookBack = 3;
1289
- while (!$foundSplitPos) {
1290
- $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
1291
- $encodedCharPos = strpos($lastChunk, "=");
1292
- if ($encodedCharPos !== false) {
1293
- // Found start of encoded character byte within $lookBack block.
1294
- // Check the encoded byte value (the 2 chars after the '=')
1295
- $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
1296
- $dec = hexdec($hex);
1297
- if ($dec < 128) { // Single byte character.
1298
- // If the encoded char was found at pos 0, it will fit
1299
- // otherwise reduce maxLength to start of the encoded char
1300
- $maxLength = ($encodedCharPos == 0) ? $maxLength :
1301
- $maxLength - ($lookBack - $encodedCharPos);
1302
- $foundSplitPos = true;
1303
- } elseif ($dec >= 192) { // First byte of a multi byte character
1304
- // Reduce maxLength to split at start of character
1305
- $maxLength = $maxLength - ($lookBack - $encodedCharPos);
1306
- $foundSplitPos = true;
1307
- } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
1308
- $lookBack += 3;
1309
- }
1310
- } else {
1311
- // No encoded character found
1312
- $foundSplitPos = true;
1313
- }
1314
- }
1315
- return $maxLength;
1316
- }
1317
-
1318
-
1319
- /**
1320
- * Set the body wrapping.
1321
- * @access public
1322
- * @return void
1323
- */
1324
- public function SetWordWrap() {
1325
- if($this->WordWrap < 1) {
1326
- return;
1327
- }
1328
-
1329
- switch($this->message_type) {
1330
- case 'alt':
1331
- case 'alt_inline':
1332
- case 'alt_attach':
1333
- case 'alt_inline_attach':
1334
- $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
1335
- break;
1336
- default:
1337
- $this->Body = $this->WrapText($this->Body, $this->WordWrap);
1338
- break;
1339
- }
1340
- }
1341
-
1342
- /**
1343
- * Assembles message header.
1344
- * @access public
1345
- * @return string The assembled header
1346
- */
1347
- public function CreateHeader() {
1348
- $result = '';
1349
-
1350
- // Set the boundaries
1351
- $uniq_id = md5(uniqid(time()));
1352
- $this->boundary[1] = 'b1_' . $uniq_id;
1353
- $this->boundary[2] = 'b2_' . $uniq_id;
1354
- $this->boundary[3] = 'b3_' . $uniq_id;
1355
-
1356
- if ($this->MessageDate == '') {
1357
- $result .= $this->HeaderLine('Date', self::RFCDate());
1358
- } else {
1359
- $result .= $this->HeaderLine('Date', $this->MessageDate);
1360
- }
1361
-
1362
- if ($this->ReturnPath) {
1363
- $result .= $this->HeaderLine('Return-Path', trim($this->ReturnPath));
1364
- } elseif ($this->Sender == '') {
1365
- $result .= $this->HeaderLine('Return-Path', trim($this->From));
1366
- } else {
1367
- $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
1368
- }
1369
-
1370
- // To be created automatically by mail()
1371
- if($this->Mailer != 'mail') {
1372
- if ($this->SingleTo === true) {
1373
- foreach($this->to as $t) {
1374
- $this->SingleToArray[] = $this->AddrFormat($t);
1375
- }
1376
- } else {
1377
- if(count($this->to) > 0) {
1378
- $result .= $this->AddrAppend('To', $this->to);
1379
- } elseif (count($this->cc) == 0) {
1380
- $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
1381
- }
1382
- }
1383
- }
1384
-
1385
- $from = array();
1386
- $from[0][0] = trim($this->From);
1387
- $from[0][1] = $this->FromName;
1388
- $result .= $this->AddrAppend('From', $from);
1389
-
1390
- // sendmail and mail() extract Cc from the header before sending
1391
- if(count($this->cc) > 0) {
1392
- $result .= $this->AddrAppend('Cc', $this->cc);
1393
- }
1394
-
1395
- // sendmail and mail() extract Bcc from the header before sending
1396
- if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
1397
- $result .= $this->AddrAppend('Bcc', $this->bcc);
1398
- }
1399
-
1400
- if(count($this->ReplyTo) > 0) {
1401
- $result .= $this->AddrAppend('Reply-To', $this->ReplyTo);
1402
- }
1403
-
1404
- // mail() sets the subject itself
1405
- if($this->Mailer != 'mail') {
1406
- $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
1407
- }
1408
-
1409
- if($this->MessageID != '') {
1410
- $result .= $this->HeaderLine('Message-ID', $this->MessageID);
1411
- } else {
1412
- $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
1413
- }
1414
- $result .= $this->HeaderLine('X-Priority', $this->Priority);
1415
- if ($this->XMailer == '') {
1416
- $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (http://code.google.com/a/apache-extras.org/p/phpmailer/)');
1417
- } else {
1418
- $myXmailer = trim($this->XMailer);
1419
- if ($myXmailer) {
1420
- $result .= $this->HeaderLine('X-Mailer', $myXmailer);
1421
- }
1422
- }
1423
-
1424
- if($this->ConfirmReadingTo != '') {
1425
- $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
1426
- }
1427
-
1428
- // Add custom headers
1429
- for($index = 0; $index < count($this->CustomHeader); $index++) {
1430
- $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
1431
- }
1432
- if (!$this->sign_key_file) {
1433
- $result .= $this->HeaderLine('MIME-Version', '1.0');
1434
- $result .= $this->GetMailMIME();
1435
- }
1436
-
1437
- return $result;
1438
- }
1439
-
1440
- /**
1441
- * Returns the message MIME.
1442
- * @access public
1443
- * @return string
1444
- */
1445
- public function GetMailMIME() {
1446
- $result = '';
1447
- switch($this->message_type) {
1448
- case 'inline':
1449
- $result .= $this->HeaderLine('Content-Type', 'multipart/related;');
1450
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1451
- break;
1452
- case 'attach':
1453
- case 'inline_attach':
1454
- case 'alt_attach':
1455
- case 'alt_inline_attach':
1456
- $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
1457
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1458
- break;
1459
- case 'alt':
1460
- case 'alt_inline':
1461
- $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
1462
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1463
- break;
1464
- default:
1465
- // Catches case 'plain': and case '':
1466
- $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
1467
- $result .= $this->TextLine('Content-Type: '.$this->ContentType.'; charset='.$this->CharSet);
1468
- break;
1469
- }
1470
-
1471
- if($this->Mailer != 'mail') {
1472
- $result .= $this->LE;
1473
- }
1474
-
1475
- return $result;
1476
- }
1477
-
1478
- /**
1479
- * Returns the MIME message (headers and body). Only really valid post PreSend().
1480
- * @access public
1481
- * @return string
1482
- */
1483
- public function GetSentMIMEMessage() {
1484
- return $this->MIMEHeader . $this->mailHeader . self::CRLF . $this->MIMEBody;
1485
- }
1486
-
1487
-
1488
- /**
1489
- * Assembles the message body. Returns an empty string on failure.
1490
- * @access public
1491
- * @throws phpmailerException
1492
- * @return string The assembled message body
1493
- */
1494
- public function CreateBody() {
1495
- $body = '';
1496
-
1497
- if ($this->sign_key_file) {
1498
- $body .= $this->GetMailMIME().$this->LE;
1499
- }
1500
-
1501
- $this->SetWordWrap();
1502
-
1503
- switch($this->message_type) {
1504
- case 'inline':
1505
- $body .= $this->GetBoundary($this->boundary[1], '', '', '');
1506
- $body .= $this->EncodeString($this->Body, $this->Encoding);
1507
- $body .= $this->LE.$this->LE;
1508
- $body .= $this->AttachAll("inline", $this->boundary[1]);
1509
- break;
1510
- case 'attach':
1511
- $body .= $this->GetBoundary($this->boundary[1], '', '', '');
1512
- $body .= $this->EncodeString($this->Body, $this->Encoding);
1513
- $body .= $this->LE.$this->LE;
1514
- $body .= $this->AttachAll("attachment", $this->boundary[1]);
1515
- break;
1516
- case 'inline_attach':
1517
- $body .= $this->TextLine("--" . $this->boundary[1]);
1518
- $body .= $this->HeaderLine('Content-Type', 'multipart/related;');
1519
- $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"');
1520
- $body .= $this->LE;
1521
- $body .= $this->GetBoundary($this->boundary[2], '', '', '');
1522
- $body .= $this->EncodeString($this->Body, $this->Encoding);
1523
- $body .= $this->LE.$this->LE;
1524
- $body .= $this->AttachAll("inline", $this->boundary[2]);
1525
- $body .= $this->LE;
1526
- $body .= $this->AttachAll("attachment", $this->boundary[1]);
1527
- break;
1528
- case 'alt':
1529
- $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
1530
- $body .= $this->EncodeString($this->AltBody, $this->Encoding);
1531
- $body .= $this->LE.$this->LE;
1532
- $body .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
1533
- $body .= $this->EncodeString($this->Body, $this->Encoding);
1534
- $body .= $this->LE.$this->LE;
1535
- $body .= $this->EndBoundary($this->boundary[1]);
1536
- break;
1537
- case 'alt_inline':
1538
- $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
1539
- $body .= $this->EncodeString($this->AltBody, $this->Encoding);
1540
- $body .= $this->LE.$this->LE;
1541
- $body .= $this->TextLine("--" . $this->boundary[1]);
1542
- $body .= $this->HeaderLine('Content-Type', 'multipart/related;');
1543
- $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"');
1544
- $body .= $this->LE;
1545
- $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '');
1546
- $body .= $this->EncodeString($this->Body, $this->Encoding);
1547
- $body .= $this->LE.$this->LE;
1548
- $body .= $this->AttachAll("inline", $this->boundary[2]);
1549
- $body .= $this->LE;
1550
- $body .= $this->EndBoundary($this->boundary[1]);
1551
- break;
1552
- case 'alt_attach':
1553
- $body .= $this->TextLine("--" . $this->boundary[1]);
1554
- $body .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
1555
- $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"');
1556
- $body .= $this->LE;
1557
- $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '');
1558
- $body .= $this->EncodeString($this->AltBody, $this->Encoding);
1559
- $body .= $this->LE.$this->LE;
1560
- $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '');
1561
- $body .= $this->EncodeString($this->Body, $this->Encoding);
1562
- $body .= $this->LE.$this->LE;
1563
- $body .= $this->EndBoundary($this->boundary[2]);
1564
- $body .= $this->LE;
1565
- $body .= $this->AttachAll("attachment", $this->boundary[1]);
1566
- break;
1567
- case 'alt_inline_attach':
1568
- $body .= $this->TextLine("--" . $this->boundary[1]);
1569
- $body .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
1570
- $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"');
1571
- $body .= $this->LE;
1572
- $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '');
1573
- $body .= $this->EncodeString($this->AltBody, $this->Encoding);
1574
- $body .= $this->LE.$this->LE;
1575
- $body .= $this->TextLine("--" . $this->boundary[2]);
1576
- $body .= $this->HeaderLine('Content-Type', 'multipart/related;');
1577
- $body .= $this->TextLine("\tboundary=\"" . $this->boundary[3] . '"');
1578
- $body .= $this->LE;
1579
- $body .= $this->GetBoundary($this->boundary[3], '', 'text/html', '');
1580
- $body .= $this->EncodeString($this->Body, $this->Encoding);
1581
- $body .= $this->LE.$this->LE;
1582
- $body .= $this->AttachAll("inline", $this->boundary[3]);
1583
- $body .= $this->LE;
1584
- $body .= $this->EndBoundary($this->boundary[2]);
1585
- $body .= $this->LE;
1586
- $body .= $this->AttachAll("attachment", $this->boundary[1]);
1587
- break;
1588
- default:
1589
- // catch case 'plain' and case ''
1590
- $body .= $this->EncodeString($this->Body, $this->Encoding);
1591
- break;
1592
- }
1593
-
1594
- if ($this->IsError()) {
1595
- $body = '';
1596
- } elseif ($this->sign_key_file) {
1597
- try {
1598
- $file = tempnam('', 'mail');
1599
- file_put_contents($file, $body); //TODO check this worked
1600
- $signed = tempnam("", "signed");
1601
- if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) {
1602
- @unlink($file);
1603
- $body = file_get_contents($signed);
1604
- @unlink($signed);
1605
- } else {
1606
- @unlink($file);
1607
- @unlink($signed);
1608
- throw new phpmailerException($this->Lang("signing").openssl_error_string());
1609
- }
1610
- } catch (phpmailerException $e) {
1611
- $body = '';
1612
- if ($this->exceptions) {
1613
- throw $e;
1614
- }
1615
- }
1616
- }
1617
-
1618
- return $body;
1619
- }
1620
-
1621
- /**
1622
- * Returns the start of a message boundary.
1623
- * @access protected
1624
- * @param string $boundary
1625
- * @param string $charSet
1626
- * @param string $contentType
1627
- * @param string $encoding
1628
- * @return string
1629
- */
1630
- protected function GetBoundary($boundary, $charSet, $contentType, $encoding) {
1631
- $result = '';
1632
- if($charSet == '') {
1633
- $charSet = $this->CharSet;
1634
- }
1635
- if($contentType == '') {
1636
- $contentType = $this->ContentType;
1637
- }
1638
- if($encoding == '') {
1639
- $encoding = $this->Encoding;
1640
- }
1641
- $result .= $this->TextLine('--' . $boundary);
1642
- $result .= sprintf("Content-Type: %s; charset=%s", $contentType, $charSet);
1643
- $result .= $this->LE;
1644
- $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
1645
- $result .= $this->LE;
1646
-
1647
- return $result;
1648
- }
1649
-
1650
- /**
1651
- * Returns the end of a message boundary.
1652
- * @access protected
1653
- * @param string $boundary
1654
- * @return string
1655
- */
1656
- protected function EndBoundary($boundary) {
1657
- return $this->LE . '--' . $boundary . '--' . $this->LE;
1658
- }
1659
-
1660
- /**
1661
- * Sets the message type.
1662
- * @access protected
1663
- * @return void
1664
- */
1665
- protected function SetMessageType() {
1666
- $this->message_type = array();
1667
- if($this->AlternativeExists()) $this->message_type[] = "alt";
1668
- if($this->InlineImageExists()) $this->message_type[] = "inline";
1669
- if($this->AttachmentExists()) $this->message_type[] = "attach";
1670
- $this->message_type = implode("_", $this->message_type);
1671
- if($this->message_type == "") $this->message_type = "plain";
1672
- }
1673
-
1674
- /**
1675
- * Returns a formatted header line.
1676
- * @access public
1677
- * @param string $name
1678
- * @param string $value
1679
- * @return string
1680
- */
1681
- public function HeaderLine($name, $value) {
1682
- return $name . ': ' . $value . $this->LE;
1683
- }
1684
-
1685
- /**
1686
- * Returns a formatted mail line.
1687
- * @access public
1688
- * @param string $value
1689
- * @return string
1690
- */
1691
- public function TextLine($value) {
1692
- return $value . $this->LE;
1693
- }
1694
-
1695
- /////////////////////////////////////////////////
1696
- // CLASS METHODS, ATTACHMENTS
1697
- /////////////////////////////////////////////////
1698
-
1699
- /**
1700
- * Adds an attachment from a path on the filesystem.
1701
- * Returns false if the file could not be found
1702
- * or accessed.
1703
- * @param string $path Path to the attachment.
1704
- * @param string $name Overrides the attachment name.
1705
- * @param string $encoding File encoding (see $Encoding).
1706
- * @param string $type File extension (MIME) type.
1707
- * @throws phpmailerException
1708
- * @return bool
1709
- */
1710
- public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1711
- try {
1712
- if ( !@is_file($path) ) {
1713
- throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
1714
- }
1715
- $filename = basename($path);
1716
- if ( $name == '' ) {
1717
- $name = $filename;
1718
- }
1719
-
1720
- $this->attachment[] = array(
1721
- 0 => $path,
1722
- 1 => $filename,
1723
- 2 => $name,
1724
- 3 => $encoding,
1725
- 4 => $type,
1726
- 5 => false, // isStringAttachment
1727
- 6 => 'attachment',
1728
- 7 => 0
1729
- );
1730
-
1731
- } catch (phpmailerException $e) {
1732
- $this->SetError($e->getMessage());
1733
- if ($this->exceptions) {
1734
- throw $e;
1735
- }
1736
- if ($this->SMTPDebug) {
1737
- $this->edebug($e->getMessage()."\n");
1738
- }
1739
- if ( $e->getCode() == self::STOP_CRITICAL ) {
1740
- return false;
1741
- }
1742
- }
1743
- return true;
1744
- }
1745
-
1746
- /**
1747
- * Return the current array of attachments
1748
- * @return array
1749
- */
1750
- public function GetAttachments() {
1751
- return $this->attachment;
1752
- }
1753
-
1754
- /**
1755
- * Attaches all fs, string, and binary attachments to the message.
1756
- * Returns an empty string on failure.
1757
- * @access protected
1758
- * @param string $disposition_type
1759
- * @param string $boundary
1760
- * @return string
1761
- */
1762
- protected function AttachAll($disposition_type, $boundary) {
1763
- // Return text of body
1764
- $mime = array();
1765
- $cidUniq = array();
1766
- $incl = array();
1767
-
1768
- // Add all attachments
1769
- foreach ($this->attachment as $attachment) {
1770
- // CHECK IF IT IS A VALID DISPOSITION_FILTER
1771
- if($attachment[6] == $disposition_type) {
1772
- // Check for string attachment
1773
- $string = '';
1774
- $path = '';
1775
- $bString = $attachment[5];
1776
- if ($bString) {
1777
- $string = $attachment[0];
1778
- } else {
1779
- $path = $attachment[0];
1780
- }
1781
-
1782
- $inclhash = md5(serialize($attachment));
1783
- if (in_array($inclhash, $incl)) { continue; }
1784
- $incl[] = $inclhash;
1785
- $filename = $attachment[1];
1786
- $name = $attachment[2];
1787
- $encoding = $attachment[3];
1788
- $type = $attachment[4];
1789
- $disposition = $attachment[6];
1790
- $cid = $attachment[7];
1791
- if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; }
1792
- $cidUniq[$cid] = true;
1793
-
1794
- $mime[] = sprintf("--%s%s", $boundary, $this->LE);
1795
- $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE);
1796
- $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
1797
-
1798
- if($disposition == 'inline') {
1799
- $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
1800
- }
1801
-
1802
- $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE);
1803
-
1804
- // Encode as string attachment
1805
- if($bString) {
1806
- $mime[] = $this->EncodeString($string, $encoding);
1807
- if($this->IsError()) {
1808
- return '';
1809
- }
1810
- $mime[] = $this->LE.$this->LE;
1811
- } else {
1812
- $mime[] = $this->EncodeFile($path, $encoding);
1813
- if($this->IsError()) {
1814
- return '';
1815
- }
1816
- $mime[] = $this->LE.$this->LE;
1817
- }
1818
- }
1819
- }
1820
-
1821
- $mime[] = sprintf("--%s--%s", $boundary, $this->LE);
1822
-
1823
- return implode("", $mime);
1824
- }
1825
-
1826
- /**
1827
- * Encodes attachment in requested format.
1828
- * Returns an empty string on failure.
1829
- * @param string $path The full path to the file
1830
- * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
1831
- * @throws phpmailerException
1832
- * @see EncodeFile()
1833
- * @access protected
1834
- * @return string
1835
- */
1836
- protected function EncodeFile($path, $encoding = 'base64') {
1837
- try {
1838
- if (!is_readable($path)) {
1839
- throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
1840
- }
1841
- $magic_quotes = get_magic_quotes_runtime();
1842
- if ($magic_quotes) {
1843
- if (version_compare(PHP_VERSION, '5.3.0', '<')) {
1844
- set_magic_quotes_runtime(0);
1845
- } else {
1846
- ini_set('magic_quotes_runtime', 0);
1847
- }
1848
- }
1849
- $file_buffer = file_get_contents($path);
1850
- $file_buffer = $this->EncodeString($file_buffer, $encoding);
1851
- if ($magic_quotes) {
1852
- if (version_compare(PHP_VERSION, '5.3.0', '<')) {
1853
- set_magic_quotes_runtime($magic_quotes);
1854
- } else {
1855
- ini_set('magic_quotes_runtime', $magic_quotes);
1856
- }
1857
- }
1858
- return $file_buffer;
1859
- } catch (Exception $e) {
1860
- $this->SetError($e->getMessage());
1861
- return '';
1862
- }
1863
- }
1864
-
1865
- /**
1866
- * Encodes string to requested format.
1867
- * Returns an empty string on failure.
1868
- * @param string $str The text to encode
1869
- * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
1870
- * @access public
1871
- * @return string
1872
- */
1873
- public function EncodeString($str, $encoding = 'base64') {
1874
- $encoded = '';
1875
- switch(strtolower($encoding)) {
1876
- case 'base64':
1877
- $encoded = chunk_split(base64_encode($str), 76, $this->LE);
1878
- break;
1879
- case '7bit':
1880
- case '8bit':
1881
- $encoded = $this->FixEOL($str);
1882
- //Make sure it ends with a line break
1883
- if (substr($encoded, -(strlen($this->LE))) != $this->LE)
1884
- $encoded .= $this->LE;
1885
- break;
1886
- case 'binary':
1887
- $encoded = $str;
1888
- break;
1889
- case 'quoted-printable':
1890
- $encoded = $this->EncodeQP($str);
1891
- break;
1892
- default:
1893
- $this->SetError($this->Lang('encoding') . $encoding);
1894
- break;
1895
- }
1896
- return $encoded;
1897
- }
1898
-
1899
- /**
1900
- * Encode a header string to best (shortest) of Q, B, quoted or none.
1901
- * @access public
1902
- * @param string $str
1903
- * @param string $position
1904
- * @return string
1905
- */
1906
- public function EncodeHeader($str, $position = 'text') {
1907
- $x = 0;
1908
-
1909
- switch (strtolower($position)) {
1910
- case 'phrase':
1911
- if (!preg_match('/[\200-\377]/', $str)) {
1912
- // Can't use addslashes as we don't know what value has magic_quotes_sybase
1913
- $encoded = addcslashes($str, "\0..\37\177\\\"");
1914
- if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
1915
- return ($encoded);
1916
- } else {
1917
- return ("\"$encoded\"");
1918
- }
1919
- }
1920
- $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
1921
- break;
1922
- case 'comment':
1923
- $x = preg_match_all('/[()"]/', $str, $matches);
1924
- // Fall-through
1925
- case 'text':
1926
- default:
1927
- $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
1928
- break;
1929
- }
1930
-
1931
- if ($x == 0) {
1932
- return ($str);
1933
- }
1934
-
1935
- $maxlen = 75 - 7 - strlen($this->CharSet);
1936
- // Try to select the encoding which should produce the shortest output
1937
- if (strlen($str)/3 < $x) {
1938
- $encoding = 'B';
1939
- if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
1940
- // Use a custom function which correctly encodes and wraps long
1941
- // multibyte strings without breaking lines within a character
1942
- $encoded = $this->Base64EncodeWrapMB($str, "\n");
1943
- } else {
1944
- $encoded = base64_encode($str);
1945
- $maxlen -= $maxlen % 4;
1946
- $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
1947
- }
1948
- } else {
1949
- $encoding = 'Q';
1950
- $encoded = $this->EncodeQ($str, $position);
1951
- $encoded = $this->WrapText($encoded, $maxlen, true);
1952
- $encoded = str_replace('='.self::CRLF, "\n", trim($encoded));
1953
- }
1954
-
1955
- $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
1956
- $encoded = trim(str_replace("\n", $this->LE, $encoded));
1957
-
1958
- return $encoded;
1959
- }
1960
-
1961
- /**
1962
- * Checks if a string contains multibyte characters.
1963
- * @access public
1964
- * @param string $str multi-byte text to wrap encode
1965
- * @return bool
1966
- */
1967
- public function HasMultiBytes($str) {
1968
- if (function_exists('mb_strlen')) {
1969
- return (strlen($str) > mb_strlen($str, $this->CharSet));
1970
- } else { // Assume no multibytes (we can't handle without mbstring functions anyway)
1971
- return false;
1972
- }
1973
- }
1974
-
1975
- /**
1976
- * Correctly encodes and wraps long multibyte strings for mail headers
1977
- * without breaking lines within a character.
1978
- * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
1979
- * @access public
1980
- * @param string $str multi-byte text to wrap encode
1981
- * @param string $lf string to use as linefeed/end-of-line
1982
- * @return string
1983
- */
1984
- public function Base64EncodeWrapMB($str, $lf=null) {
1985
- $start = "=?".$this->CharSet."?B?";
1986
- $end = "?=";
1987
- $encoded = "";
1988
- if ($lf === null) {
1989
- $lf = $this->LE;
1990
- }
1991
-
1992
- $mb_length = mb_strlen($str, $this->CharSet);
1993
- // Each line must have length <= 75, including $start and $end
1994
- $length = 75 - strlen($start) - strlen($end);
1995
- // Average multi-byte ratio
1996
- $ratio = $mb_length / strlen($str);
1997
- // Base64 has a 4:3 ratio
1998
- $offset = $avgLength = floor($length * $ratio * .75);
1999
-
2000
- for ($i = 0; $i < $mb_length; $i += $offset) {
2001
- $lookBack = 0;
2002
-
2003
- do {
2004
- $offset = $avgLength - $lookBack;
2005
- $chunk = mb_substr($str, $i, $offset, $this->CharSet);
2006
- $chunk = base64_encode($chunk);
2007
- $lookBack++;
2008
- }
2009
- while (strlen($chunk) > $length);
2010
-
2011
- $encoded .= $chunk . $lf;
2012
- }
2013
-
2014
- // Chomp the last linefeed
2015
- $encoded = substr($encoded, 0, -strlen($lf));
2016
- return $encoded;
2017
- }
2018
-
2019
- /**
2020
- * Encode string to RFC2045 (6.7) quoted-printable format
2021
- * @access public
2022
- * @param string $string The text to encode
2023
- * @param integer $line_max Number of chars allowed on a line before wrapping
2024
- * @return string
2025
- * @link PHP version adapted from http://www.php.net/manual/en/function.quoted-printable-decode.php#89417
2026
- */
2027
- public function EncodeQP($string, $line_max = 76) {
2028
- if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3)
2029
- return quoted_printable_encode($string);
2030
- }
2031
- //Fall back to a pure PHP implementation
2032
- $string = str_replace(array('%20', '%0D%0A.', '%0D%0A', '%'), array(' ', "\r\n=2E", "\r\n", '='), rawurlencode($string));
2033
- $string = preg_replace('/[^\r\n]{'.($line_max - 3).'}[^=\r\n]{2}/', "$0=\r\n", $string);
2034
- return $string;
2035
- }
2036
-
2037
- /**
2038
- * Wrapper to preserve BC for old QP encoding function that was removed
2039
- * @see EncodeQP()
2040
- * @access public
2041
- * @param string $string
2042
- * @param integer $line_max
2043
- * @param bool $space_conv
2044
- * @return string
2045
- */
2046
- public function EncodeQPphp($string, $line_max = 76, $space_conv = false) {
2047
- return $this->EncodeQP($string, $line_max);
2048
- }
2049
-
2050
- /**
2051
- * Encode string to q encoding.
2052
- * @link http://tools.ietf.org/html/rfc2047
2053
- * @param string $str the text to encode
2054
- * @param string $position Where the text is going to be used, see the RFC for what that means
2055
- * @access public
2056
- * @return string
2057
- */
2058
- public function EncodeQ($str, $position = 'text') {
2059
- //There should not be any EOL in the string
2060
- $pattern="";
2061
- $encoded = str_replace(array("\r", "\n"), '', $str);
2062
- switch (strtolower($position)) {
2063
- case 'phrase':
2064
- $pattern = '^A-Za-z0-9!*+\/ -';
2065
- break;
2066
-
2067
- case 'comment':
2068
- $pattern = '\(\)"';
2069
- //note that we don't break here!
2070
- //for this reason we build the $pattern without including delimiters and []
2071
-
2072
- case 'text':
2073
- default:
2074
- //Replace every high ascii, control =, ? and _ characters
2075
- //We put \075 (=) as first value to make sure it's the first one in being converted, preventing double encode
2076
- $pattern = '\075\000-\011\013\014\016-\037\077\137\177-\377' . $pattern;
2077
- break;
2078
- }
2079
-
2080
- if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) {
2081
- foreach (array_unique($matches[0]) as $char) {
2082
- $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded);
2083
- }
2084
- }
2085
-
2086
- //Replace every spaces to _ (more readable than =20)
2087
- return str_replace(' ', '_', $encoded);
2088
- }
2089
-
2090
-
2091
- /**
2092
- * Adds a string or binary attachment (non-filesystem) to the list.
2093
- * This method can be used to attach ascii or binary data,
2094
- * such as a BLOB record from a database.
2095
- * @param string $string String attachment data.
2096
- * @param string $filename Name of the attachment.
2097
- * @param string $encoding File encoding (see $Encoding).
2098
- * @param string $type File extension (MIME) type.
2099
- * @return void
2100
- */
2101
- public function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {
2102
- // Append to $attachment array
2103
- $this->attachment[] = array(
2104
- 0 => $string,
2105
- 1 => $filename,
2106
- 2 => basename($filename),
2107
- 3 => $encoding,
2108
- 4 => $type,
2109
- 5 => true, // isStringAttachment
2110
- 6 => 'attachment',
2111
- 7 => 0
2112
- );
2113
- }
2114
-
2115
- /**
2116
- * Add an embedded attachment from a file.
2117
- * This can include images, sounds, and just about any other document type.
2118
- * Be sure to set the $type to an image type for images:
2119
- * JPEG images use 'image/jpeg', GIF uses 'image/gif', PNG uses 'image/png'.
2120
- * @param string $path Path to the attachment.
2121
- * @param string $cid Content ID of the attachment; Use this to reference
2122
- * the content when using an embedded image in HTML.
2123
- * @param string $name Overrides the attachment name.
2124
- * @param string $encoding File encoding (see $Encoding).
2125
- * @param string $type File MIME type.
2126
- * @return bool True on successfully adding an attachment
2127
- */
2128
- public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
2129
-
2130
- if ( !@is_file($path) ) {
2131
- $this->SetError($this->Lang('file_access') . $path);
2132
- return false;
2133
- }
2134
-
2135
- $filename = basename($path);
2136
- if ( $name == '' ) {
2137
- $name = $filename;
2138
- }
2139
-
2140
- // Append to $attachment array
2141
- $this->attachment[] = array(
2142
- 0 => $path,
2143
- 1 => $filename,
2144
- 2 => $name,
2145
- 3 => $encoding,
2146
- 4 => $type,
2147
- 5 => false, // isStringAttachment
2148
- 6 => 'inline',
2149
- 7 => $cid
2150
- );
2151
- return true;
2152
- }
2153
-
2154
-
2155
- /**
2156
- * Add an embedded stringified attachment.
2157
- * This can include images, sounds, and just about any other document type.
2158
- * Be sure to set the $type to an image type for images:
2159
- * JPEG images use 'image/jpeg', GIF uses 'image/gif', PNG uses 'image/png'.
2160
- * @param string $string The attachment binary data.
2161
- * @param string $cid Content ID of the attachment; Use this to reference
2162
- * the content when using an embedded image in HTML.
2163
- * @param string $filename A name for the attachment
2164
- * @param string $encoding File encoding (see $Encoding).
2165
- * @param string $type MIME type.
2166
- * @return bool True on successfully adding an attachment
2167
- */
2168
- public function AddStringEmbeddedImage($string, $cid, $filename = '', $encoding = 'base64', $type = 'application/octet-stream') {
2169
- // Append to $attachment array
2170
- $this->attachment[] = array(
2171
- 0 => $string,
2172
- 1 => $filename,
2173
- 2 => basename($filename),
2174
- 3 => $encoding,
2175
- 4 => $type,
2176
- 5 => true, // isStringAttachment
2177
- 6 => 'inline',
2178
- 7 => $cid
2179
- );
2180
- return true;
2181
- }
2182
-
2183
- /**
2184
- * Returns true if an inline attachment is present.
2185
- * @access public
2186
- * @return bool
2187
- */
2188
- public function InlineImageExists() {
2189
- foreach($this->attachment as $attachment) {
2190
- if ($attachment[6] == 'inline') {
2191
- return true;
2192
- }
2193
- }
2194
- return false;
2195
- }
2196
-
2197
- /**
2198
- * Returns true if an attachment (non-inline) is present.
2199
- * @return bool
2200
- */
2201
- public function AttachmentExists() {
2202
- foreach($this->attachment as $attachment) {
2203
- if ($attachment[6] == 'attachment') {
2204
- return true;
2205
- }
2206
- }
2207
- return false;
2208
- }
2209
-
2210
- /**
2211
- * Does this message have an alternative body set?
2212
- * @return bool
2213
- */
2214
- public function AlternativeExists() {
2215
- return !empty($this->AltBody);
2216
- }
2217
-
2218
- /////////////////////////////////////////////////
2219
- // CLASS METHODS, MESSAGE RESET
2220
- /////////////////////////////////////////////////
2221
-
2222
- /**
2223
- * Clears all recipients assigned in the TO array. Returns void.
2224
- * @return void
2225
- */
2226
- public function ClearAddresses() {
2227
- foreach($this->to as $to) {
2228
- unset($this->all_recipients[strtolower($to[0])]);
2229
- }
2230
- $this->to = array();
2231
- }
2232
-
2233
- /**
2234
- * Clears all recipients assigned in the CC array. Returns void.
2235
- * @return void
2236
- */
2237
- public function ClearCCs() {
2238
- foreach($this->cc as $cc) {
2239
- unset($this->all_recipients[strtolower($cc[0])]);
2240
- }
2241
- $this->cc = array();
2242
- }
2243
-
2244
- /**
2245
- * Clears all recipients assigned in the BCC array. Returns void.
2246
- * @return void
2247
- */
2248
- public function ClearBCCs() {
2249
- foreach($this->bcc as $bcc) {
2250
- unset($this->all_recipients[strtolower($bcc[0])]);
2251
- }
2252
- $this->bcc = array();
2253
- }
2254
-
2255
- /**
2256
- * Clears all recipients assigned in the ReplyTo array. Returns void.
2257
- * @return void
2258
- */
2259
- public function ClearReplyTos() {
2260
- $this->ReplyTo = array();
2261
- }
2262
-
2263
- /**
2264
- * Clears all recipients assigned in the TO, CC and BCC
2265
- * array. Returns void.
2266
- * @return void
2267
- */
2268
- public function ClearAllRecipients() {
2269
- $this->to = array();
2270
- $this->cc = array();
2271
- $this->bcc = array();
2272
- $this->all_recipients = array();
2273
- }
2274
-
2275
- /**
2276
- * Clears all previously set filesystem, string, and binary
2277
- * attachments. Returns void.
2278
- * @return void
2279
- */
2280
- public function ClearAttachments() {
2281
- $this->attachment = array();
2282
- }
2283
-
2284
- /**
2285
- * Clears all custom headers. Returns void.
2286
- * @return void
2287
- */
2288
- public function ClearCustomHeaders() {
2289
- $this->CustomHeader = array();
2290
- }
2291
-
2292
- /////////////////////////////////////////////////
2293
- // CLASS METHODS, MISCELLANEOUS
2294
- /////////////////////////////////////////////////
2295
-
2296
- /**
2297
- * Adds the error message to the error container.
2298
- * @access protected
2299
- * @param string $msg
2300
- * @return void
2301
- */
2302
- protected function SetError($msg) {
2303
- $this->error_count++;
2304
- if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
2305
- $lasterror = $this->smtp->getError();
2306
- if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
2307
- $msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
2308
- }
2309
- }
2310
- $this->ErrorInfo = $msg;
2311
- }
2312
-
2313
- /**
2314
- * Returns the proper RFC 822 formatted date.
2315
- * @access public
2316
- * @return string
2317
- * @static
2318
- */
2319
- public static function RFCDate() {
2320
- $tz = date('Z');
2321
- $tzs = ($tz < 0) ? '-' : '+';
2322
- $tz = abs($tz);
2323
- $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
2324
- $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
2325
-
2326
- return $result;
2327
- }
2328
-
2329
- /**
2330
- * Returns the server hostname or 'localhost.localdomain' if unknown.
2331
- * @access protected
2332
- * @return string
2333
- */
2334
- protected function ServerHostname() {
2335
- if (!empty($this->Hostname)) {
2336
- $result = $this->Hostname;
2337
- } elseif (isset($_SERVER['SERVER_NAME'])) {
2338
- $result = $_SERVER['SERVER_NAME'];
2339
- } else {
2340
- $result = 'localhost.localdomain';
2341
- }
2342
-
2343
- return $result;
2344
- }
2345
-
2346
- /**
2347
- * Returns a message in the appropriate language.
2348
- * @access protected
2349
- * @param string $key
2350
- * @return string
2351
- */
2352
- protected function Lang($key) {
2353
- if(count($this->language) < 1) {
2354
- $this->SetLanguage('en'); // set the default language
2355
- }
2356
-
2357
- if(isset($this->language[$key])) {
2358
- return $this->language[$key];
2359
- } else {
2360
- return 'Language string failed to load: ' . $key;
2361
- }
2362
- }
2363
-
2364
- /**
2365
- * Returns true if an error occurred.
2366
- * @access public
2367
- * @return bool
2368
- */
2369
- public function IsError() {
2370
- return ($this->error_count > 0);
2371
- }
2372
-
2373
- /**
2374
- * Changes every end of line from CRLF, CR or LF to $this->LE.
2375
- * @access public
2376
- * @param string $str String to FixEOL
2377
- * @return string
2378
- */
2379
- public function FixEOL($str) {
2380
- // condense down to \n
2381
- $nstr = str_replace(array("\r\n", "\r"), "\n", $str);
2382
- // Now convert LE as needed
2383
- if ($this->LE !== "\n") {
2384
- $nstr = str_replace("\n", $this->LE, $nstr);
2385
- }
2386
- return $nstr;
2387
- }
2388
-
2389
- /**
2390
- * Adds a custom header. $name value can be overloaded to contain
2391
- * both header name and value (name:value)
2392
- * @access public
2393
- * @param string $name custom header name
2394
- * @param string $value header value
2395
- * @return void
2396
- */
2397
- public function AddCustomHeader($name, $value=null) {
2398
- if ($value === null) {
2399
- // Value passed in as name:value
2400
- $this->CustomHeader[] = explode(':', $name, 2);
2401
- } else {
2402
- $this->CustomHeader[] = array($name, $value);
2403
- }
2404
- }
2405
-
2406
- /**
2407
- * Evaluates the message and returns modifications for inline images and backgrounds
2408
- * @access public
2409
- * @param string $message Text to be HTML modified
2410
- * @param string $basedir baseline directory for path
2411
- * @return string $message
2412
- */
2413
- public function MsgHTML($message, $basedir = '') {
2414
- preg_match_all("/(src|background)=[\"'](.*)[\"']/Ui", $message, $images);
2415
- if(isset($images[2])) {
2416
- foreach($images[2] as $i => $url) {
2417
- // do not change urls for absolute images (thanks to corvuscorax)
2418
- if (!preg_match('#^[A-z]+://#', $url)) {
2419
- $filename = basename($url);
2420
- $directory = dirname($url);
2421
- if ($directory == '.') {
2422
- $directory = '';
2423
- }
2424
- $cid = 'cid:' . md5($filename);
2425
- $ext = pathinfo($filename, PATHINFO_EXTENSION);
2426
- $mimeType = self::_mime_types($ext);
2427
- if ( strlen($basedir) > 1 && substr($basedir, -1) != '/') { $basedir .= '/'; }
2428
- if ( strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; }
2429
- if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType) ) {
2430
- $message = preg_replace("/".$images[1][$i]."=[\"']".preg_quote($url, '/')."[\"']/Ui", $images[1][$i]."=\"".$cid."\"", $message);
2431
- }
2432
- }
2433
- }
2434
- }
2435
- $this->IsHTML(true);
2436
- $this->Body = $message;
2437
- if (empty($this->AltBody)) {
2438
- $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message)));
2439
- if (!empty($textMsg)) {
2440
- $this->AltBody = html_entity_decode($textMsg, ENT_QUOTES, $this->CharSet);
2441
- }
2442
- }
2443
- if (empty($this->AltBody)) {
2444
- $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
2445
- }
2446
- return $message;
2447
- }
2448
-
2449
- /**
2450
- * Gets the MIME type of the embedded or inline image
2451
- * @param string $ext File extension
2452
- * @access public
2453
- * @return string MIME type of ext
2454
- * @static
2455
- */
2456
- public static function _mime_types($ext = '') {
2457
- $mimes = array(
2458
- 'xl' => 'application/excel',
2459
- 'hqx' => 'application/mac-binhex40',
2460
- 'cpt' => 'application/mac-compactpro',
2461
- 'bin' => 'application/macbinary',
2462
- 'doc' => 'application/msword',
2463
- 'word' => 'application/msword',
2464
- 'class' => 'application/octet-stream',
2465
- 'dll' => 'application/octet-stream',
2466
- 'dms' => 'application/octet-stream',
2467
- 'exe' => 'application/octet-stream',
2468
- 'lha' => 'application/octet-stream',
2469
- 'lzh' => 'application/octet-stream',
2470
- 'psd' => 'application/octet-stream',
2471
- 'sea' => 'application/octet-stream',
2472
- 'so' => 'application/octet-stream',
2473
- 'oda' => 'application/oda',
2474
- 'pdf' => 'application/pdf',
2475
- 'ai' => 'application/postscript',
2476
- 'eps' => 'application/postscript',
2477
- 'ps' => 'application/postscript',
2478
- 'smi' => 'application/smil',
2479
- 'smil' => 'application/smil',
2480
- 'mif' => 'application/vnd.mif',
2481
- 'xls' => 'application/vnd.ms-excel',
2482
- 'ppt' => 'application/vnd.ms-powerpoint',
2483
- 'wbxml' => 'application/vnd.wap.wbxml',
2484
- 'wmlc' => 'application/vnd.wap.wmlc',
2485
- 'dcr' => 'application/x-director',
2486
- 'dir' => 'application/x-director',
2487
- 'dxr' => 'application/x-director',
2488
- 'dvi' => 'application/x-dvi',
2489
- 'gtar' => 'application/x-gtar',
2490
- 'php3' => 'application/x-httpd-php',
2491
- 'php4' => 'application/x-httpd-php',
2492
- 'php' => 'application/x-httpd-php',
2493
- 'phtml' => 'application/x-httpd-php',
2494
- 'phps' => 'application/x-httpd-php-source',
2495
- 'js' => 'application/x-javascript',
2496
- 'swf' => 'application/x-shockwave-flash',
2497
- 'sit' => 'application/x-stuffit',
2498
- 'tar' => 'application/x-tar',
2499
- 'tgz' => 'application/x-tar',
2500
- 'xht' => 'application/xhtml+xml',
2501
- 'xhtml' => 'application/xhtml+xml',
2502
- 'zip' => 'application/zip',
2503
- 'mid' => 'audio/midi',
2504
- 'midi' => 'audio/midi',
2505
- 'mp2' => 'audio/mpeg',
2506
- 'mp3' => 'audio/mpeg',
2507
- 'mpga' => 'audio/mpeg',
2508
- 'aif' => 'audio/x-aiff',
2509
- 'aifc' => 'audio/x-aiff',
2510
- 'aiff' => 'audio/x-aiff',
2511
- 'ram' => 'audio/x-pn-realaudio',
2512
- 'rm' => 'audio/x-pn-realaudio',
2513
- 'rpm' => 'audio/x-pn-realaudio-plugin',
2514
- 'ra' => 'audio/x-realaudio',
2515
- 'wav' => 'audio/x-wav',
2516
- 'bmp' => 'image/bmp',
2517
- 'gif' => 'image/gif',
2518
- 'jpeg' => 'image/jpeg',
2519
- 'jpe' => 'image/jpeg',
2520
- 'jpg' => 'image/jpeg',
2521
- 'png' => 'image/png',
2522
- 'tiff' => 'image/tiff',
2523
- 'tif' => 'image/tiff',
2524
- 'eml' => 'message/rfc822',
2525
- 'css' => 'text/css',
2526
- 'html' => 'text/html',
2527
- 'htm' => 'text/html',
2528
- 'shtml' => 'text/html',
2529
- 'log' => 'text/plain',
2530
- 'text' => 'text/plain',
2531
- 'txt' => 'text/plain',
2532
- 'rtx' => 'text/richtext',
2533
- 'rtf' => 'text/rtf',
2534
- 'xml' => 'text/xml',
2535
- 'xsl' => 'text/xml',
2536
- 'mpeg' => 'video/mpeg',
2537
- 'mpe' => 'video/mpeg',
2538
- 'mpg' => 'video/mpeg',
2539
- 'mov' => 'video/quicktime',
2540
- 'qt' => 'video/quicktime',
2541
- 'rv' => 'video/vnd.rn-realvideo',
2542
- 'avi' => 'video/x-msvideo',
2543
- 'movie' => 'video/x-sgi-movie'
2544
- );
2545
- return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
2546
- }
2547
-
2548
- /**
2549
- * Set (or reset) Class Objects (variables)
2550
- *
2551
- * Usage Example:
2552
- * $page->set('X-Priority', '3');
2553
- *
2554
- * @access public
2555
- * @param string $name Parameter Name
2556
- * @param mixed $value Parameter Value
2557
- * NOTE: will not work with arrays, there are no arrays to set/reset
2558
- * @throws phpmailerException
2559
- * @return bool
2560
- * @todo Should this not be using __set() magic function?
2561
- */
2562
- public function set($name, $value = '') {
2563
- try {
2564
- if (isset($this->$name) ) {
2565
- $this->$name = $value;
2566
- } else {
2567
- throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL);
2568
- }
2569
- } catch (Exception $e) {
2570
- $this->SetError($e->getMessage());
2571
- if ($e->getCode() == self::STOP_CRITICAL) {
2572
- return false;
2573
- }
2574
- }
2575
- return true;
2576
- }
2577
-
2578
- /**
2579
- * Strips newlines to prevent header injection.
2580
- * @access public
2581
- * @param string $str String
2582
- * @return string
2583
- */
2584
- public function SecureHeader($str) {
2585
- return trim(str_replace(array("\r", "\n"), '', $str));
2586
- }
2587
-
2588
- /**
2589
- * Set the private key file and password to sign the message.
2590
- *
2591
- * @access public
2592
- * @param $cert_filename
2593
- * @param string $key_filename Parameter File Name
2594
- * @param string $key_pass Password for private key
2595
- */
2596
- public function Sign($cert_filename, $key_filename, $key_pass) {
2597
- $this->sign_cert_file = $cert_filename;
2598
- $this->sign_key_file = $key_filename;
2599
- $this->sign_key_pass = $key_pass;
2600
- }
2601
-
2602
- /**
2603
- * Set the private key file and password to sign the message.
2604
- *
2605
- * @access public
2606
- * @param string $txt
2607
- * @return string
2608
- */
2609
- public function DKIM_QP($txt) {
2610
- $line = '';
2611
- for ($i = 0; $i < strlen($txt); $i++) {
2612
- $ord = ord($txt[$i]);
2613
- if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) {
2614
- $line .= $txt[$i];
2615
- } else {
2616
- $line .= "=".sprintf("%02X", $ord);
2617
- }
2618
- }
2619
- return $line;
2620
- }
2621
-
2622
- /**
2623
- * Generate DKIM signature
2624
- *
2625
- * @access public
2626
- * @param string $s Header
2627
- * @return string
2628
- */
2629
- public function DKIM_Sign($s) {
2630
- $privKeyStr = file_get_contents($this->DKIM_private);
2631
- if ($this->DKIM_passphrase != '') {
2632
- $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
2633
- } else {
2634
- $privKey = $privKeyStr;
2635
- }
2636
- if (openssl_sign($s, $signature, $privKey)) {
2637
- return base64_encode($signature);
2638
- }
2639
- return '';
2640
- }
2641
-
2642
- /**
2643
- * Generate DKIM Canonicalization Header
2644
- *
2645
- * @access public
2646
- * @param string $s Header
2647
- * @return string
2648
- */
2649
- public function DKIM_HeaderC($s) {
2650
- $s = preg_replace("/\r\n\s+/", " ", $s);
2651
- $lines = explode("\r\n", $s);
2652
- foreach ($lines as $key => $line) {
2653
- list($heading, $value) = explode(":", $line, 2);
2654
- $heading = strtolower($heading);
2655
- $value = preg_replace("/\s+/", " ", $value) ; // Compress useless spaces
2656
- $lines[$key] = $heading.":".trim($value) ; // Don't forget to remove WSP around the value
2657
- }
2658
- $s = implode("\r\n", $lines);
2659
- return $s;
2660
- }
2661
-
2662
- /**
2663
- * Generate DKIM Canonicalization Body
2664
- *
2665
- * @access public
2666
- * @param string $body Message Body
2667
- * @return string
2668
- */
2669
- public function DKIM_BodyC($body) {
2670
- if ($body == '') return "\r\n";
2671
- // stabilize line endings
2672
- $body = str_replace("\r\n", "\n", $body);
2673
- $body = str_replace("\n", "\r\n", $body);
2674
- // END stabilize line endings
2675
- while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") {
2676
- $body = substr($body, 0, strlen($body) - 2);
2677
- }
2678
- return $body;
2679
- }
2680
-
2681
- /**
2682
- * Create the DKIM header, body, as new header
2683
- *
2684
- * @access public
2685
- * @param string $headers_line Header lines
2686
- * @param string $subject Subject
2687
- * @param string $body Body
2688
- * @return string
2689
- */
2690
- public function DKIM_Add($headers_line, $subject, $body) {
2691
- $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms
2692
- $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
2693
- $DKIMquery = 'dns/txt'; // Query method
2694
- $DKIMtime = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
2695
- $subject_header = "Subject: $subject";
2696
- $headers = explode($this->LE, $headers_line);
2697
- $from_header = "";
2698
- $to_header = "";
2699
- foreach($headers as $header) {
2700
- if (strpos($header, 'From:') === 0) {
2701
- $from_header = $header;
2702
- } elseif (strpos($header, 'To:') === 0) {
2703
- $to_header = $header;
2704
- }
2705
- }
2706
- $from = str_replace('|', '=7C', $this->DKIM_QP($from_header));
2707
- $to = str_replace('|', '=7C', $this->DKIM_QP($to_header));
2708
- $subject = str_replace('|', '=7C', $this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable
2709
- $body = $this->DKIM_BodyC($body);
2710
- $DKIMlen = strlen($body) ; // Length of body
2711
- $DKIMb64 = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body
2712
- $ident = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";";
2713
- $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n".
2714
- "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n".
2715
- "\th=From:To:Subject;\r\n".
2716
- "\td=" . $this->DKIM_domain . ";" . $ident . "\r\n".
2717
- "\tz=$from\r\n".
2718
- "\t|$to\r\n".
2719
- "\t|$subject;\r\n".
2720
- "\tbh=" . $DKIMb64 . ";\r\n".
2721
- "\tb=";
2722
- $toSign = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs);
2723
- $signed = $this->DKIM_Sign($toSign);
2724
- return "X-PHPMAILER-DKIM: code.google.com/a/apache-extras.org/p/phpmailer/\r\n".$dkimhdrs.$signed."\r\n";
2725
- }
2726
-
2727
- /**
2728
- * Perform callback
2729
- * @param boolean $isSent
2730
- * @param string $to
2731
- * @param string $cc
2732
- * @param string $bcc
2733
- * @param string $subject
2734
- * @param string $body
2735
- * @param string $from
2736
- */
2737
- protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from = null) {
2738
- if (!empty($this->action_function) && is_callable($this->action_function)) {
2739
- $params = array($isSent, $to, $cc, $bcc, $subject, $body, $from);
2740
- call_user_func_array($this->action_function, $params);
2741
- }
2742
- }
2743
- }
2744
-
2745
- /**
2746
- * Exception handler for PHPMailer
2747
- * @package PHPMailer
2748
- */
2749
- class phpmailerException extends Exception {
2750
- /**
2751
- * Prettify error message output
2752
- * @return string
2753
- */
2754
- public function errorMessage() {
2755
- $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
2756
- return $errorMsg;
2757
- }
2758
- }