dependabot-linguist 0.212.0 → 0.212.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,1075 +0,0 @@
1
- <?php
2
- /*~ class.smtp.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 SMTP email transport class
27
- * NOTE: Designed for use with PHP version 5 and up
28
- * @package PHPMailer
29
- * @author Andy Prevost
30
- * @author Marcus Bointon
31
- * @copyright 2004 - 2008 Andy Prevost
32
- * @author Jim Jagielski
33
- * @copyright 2010 - 2012 Jim Jagielski
34
- * @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL)
35
- */
36
-
37
- /**
38
- * PHP RFC821 SMTP client
39
- *
40
- * Implements all the RFC 821 SMTP commands except TURN which will always return a not implemented error.
41
- * SMTP also provides some utility methods for sending mail to an SMTP server.
42
- * @author Chris Ryan
43
- * @package PHPMailer
44
- */
45
-
46
- class SMTP {
47
- /**
48
- * SMTP server port
49
- * @var int
50
- */
51
- public $SMTP_PORT = 25;
52
-
53
- /**
54
- * SMTP reply line ending (don't change)
55
- * @var string
56
- */
57
- public $CRLF = "\r\n";
58
-
59
- /**
60
- * Debug output level; 0 for no output
61
- * @var int
62
- */
63
- public $do_debug = 0;
64
-
65
- /**
66
- * Sets the function/method to use for debugging output.
67
- * Right now we only honor "echo" or "error_log"
68
- * @var string
69
- */
70
- public $Debugoutput = "echo";
71
-
72
- /**
73
- * Sets VERP use on/off (default is off)
74
- * @var bool
75
- */
76
- public $do_verp = false;
77
-
78
- /**
79
- * Sets the SMTP timeout value for reads, in seconds
80
- * @var int
81
- */
82
- public $Timeout = 15;
83
-
84
- /**
85
- * Sets the SMTP timelimit value for reads, in seconds
86
- * @var int
87
- */
88
- public $Timelimit = 30;
89
-
90
- /**
91
- * Sets the SMTP PHPMailer Version number
92
- * @var string
93
- */
94
- public $Version = '5.2.2';
95
-
96
- /////////////////////////////////////////////////
97
- // PROPERTIES, PRIVATE AND PROTECTED
98
- /////////////////////////////////////////////////
99
-
100
- /**
101
- * @var resource The socket to the server
102
- */
103
- private $smtp_conn;
104
- /**
105
- * @var string Error message, if any, for the last call
106
- */
107
- private $error;
108
- /**
109
- * @var string The reply the server sent to us for HELO
110
- */
111
- private $helo_rply;
112
-
113
- /**
114
- * Outputs debugging info via user-defined method
115
- * @param string $str
116
- */
117
- private function edebug($str) {
118
- if ($this->Debugoutput == "error_log") {
119
- error_log($str);
120
- } else {
121
- echo $str;
122
- }
123
- }
124
-
125
- /**
126
- * Initialize the class so that the data is in a known state.
127
- * @access public
128
- * @return SMTP
129
- */
130
- public function __construct() {
131
- $this->smtp_conn = 0;
132
- $this->error = null;
133
- $this->helo_rply = null;
134
-
135
- $this->do_debug = 0;
136
- }
137
-
138
- /////////////////////////////////////////////////
139
- // CONNECTION FUNCTIONS
140
- /////////////////////////////////////////////////
141
-
142
- /**
143
- * Connect to the server specified on the port specified.
144
- * If the port is not specified use the default SMTP_PORT.
145
- * If tval is specified then a connection will try and be
146
- * established with the server for that number of seconds.
147
- * If tval is not specified the default is 30 seconds to
148
- * try on the connection.
149
- *
150
- * SMTP CODE SUCCESS: 220
151
- * SMTP CODE FAILURE: 421
152
- * @access public
153
- * @param string $host
154
- * @param int $port
155
- * @param int $tval
156
- * @return bool
157
- */
158
- public function Connect($host, $port = 0, $tval = 30) {
159
- // set the error val to null so there is no confusion
160
- $this->error = null;
161
-
162
- // make sure we are __not__ connected
163
- if($this->connected()) {
164
- // already connected, generate error
165
- $this->error = array("error" => "Already connected to a server");
166
- return false;
167
- }
168
-
169
- if(empty($port)) {
170
- $port = $this->SMTP_PORT;
171
- }
172
-
173
- // connect to the smtp server
174
- $this->smtp_conn = @fsockopen($host, // the host of the server
175
- $port, // the port to use
176
- $errno, // error number if any
177
- $errstr, // error message if any
178
- $tval); // give up after ? secs
179
- // verify we connected properly
180
- if(empty($this->smtp_conn)) {
181
- $this->error = array("error" => "Failed to connect to server",
182
- "errno" => $errno,
183
- "errstr" => $errstr);
184
- if($this->do_debug >= 1) {
185
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />');
186
- }
187
- return false;
188
- }
189
-
190
- // SMTP server can take longer to respond, give longer timeout for first read
191
- // Windows does not have support for this timeout function
192
- if(substr(PHP_OS, 0, 3) != "WIN") {
193
- $max = ini_get('max_execution_time');
194
- if ($max != 0 && $tval > $max) { // don't bother if unlimited
195
- @set_time_limit($tval);
196
- }
197
- stream_set_timeout($this->smtp_conn, $tval, 0);
198
- }
199
-
200
- // get any announcement
201
- $announce = $this->get_lines();
202
-
203
- if($this->do_debug >= 2) {
204
- $this->edebug("SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />');
205
- }
206
-
207
- return true;
208
- }
209
-
210
- /**
211
- * Initiate a TLS communication with the server.
212
- *
213
- * SMTP CODE 220 Ready to start TLS
214
- * SMTP CODE 501 Syntax error (no parameters allowed)
215
- * SMTP CODE 454 TLS not available due to temporary reason
216
- * @access public
217
- * @return bool success
218
- */
219
- public function StartTLS() {
220
- $this->error = null; # to avoid confusion
221
-
222
- if(!$this->connected()) {
223
- $this->error = array("error" => "Called StartTLS() without being connected");
224
- return false;
225
- }
226
-
227
- fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
228
-
229
- $rply = $this->get_lines();
230
- $code = substr($rply,0,3);
231
-
232
- if($this->do_debug >= 2) {
233
- $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
234
- }
235
-
236
- if($code != 220) {
237
- $this->error =
238
- array("error" => "STARTTLS not accepted from server",
239
- "smtp_code" => $code,
240
- "smtp_msg" => substr($rply,4));
241
- if($this->do_debug >= 1) {
242
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
243
- }
244
- return false;
245
- }
246
-
247
- // Begin encrypted connection
248
- if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
249
- return false;
250
- }
251
-
252
- return true;
253
- }
254
-
255
- /**
256
- * Performs SMTP authentication. Must be run after running the
257
- * Hello() method. Returns true if successfully authenticated.
258
- * @access public
259
- * @param string $username
260
- * @param string $password
261
- * @param string $authtype
262
- * @param string $realm
263
- * @param string $workstation
264
- * @return bool
265
- */
266
- public function Authenticate($username, $password, $authtype='LOGIN', $realm='', $workstation='') {
267
- if (empty($authtype)) {
268
- $authtype = 'LOGIN';
269
- }
270
-
271
- switch ($authtype) {
272
- case 'PLAIN':
273
- // Start authentication
274
- fputs($this->smtp_conn,"AUTH PLAIN" . $this->CRLF);
275
-
276
- $rply = $this->get_lines();
277
- $code = substr($rply,0,3);
278
-
279
- if($code != 334) {
280
- $this->error =
281
- array("error" => "AUTH not accepted from server",
282
- "smtp_code" => $code,
283
- "smtp_msg" => substr($rply,4));
284
- if($this->do_debug >= 1) {
285
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
286
- }
287
- return false;
288
- }
289
- // Send encoded username and password
290
- fputs($this->smtp_conn, base64_encode("\0".$username."\0".$password) . $this->CRLF);
291
-
292
- $rply = $this->get_lines();
293
- $code = substr($rply,0,3);
294
-
295
- if($code != 235) {
296
- $this->error =
297
- array("error" => "Authentication not accepted from server",
298
- "smtp_code" => $code,
299
- "smtp_msg" => substr($rply,4));
300
- if($this->do_debug >= 1) {
301
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
302
- }
303
- return false;
304
- }
305
- break;
306
- case 'LOGIN':
307
- // Start authentication
308
- fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
309
-
310
- $rply = $this->get_lines();
311
- $code = substr($rply,0,3);
312
-
313
- if($code != 334) {
314
- $this->error =
315
- array("error" => "AUTH not accepted from server",
316
- "smtp_code" => $code,
317
- "smtp_msg" => substr($rply,4));
318
- if($this->do_debug >= 1) {
319
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
320
- }
321
- return false;
322
- }
323
-
324
- // Send encoded username
325
- fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
326
-
327
- $rply = $this->get_lines();
328
- $code = substr($rply,0,3);
329
-
330
- if($code != 334) {
331
- $this->error =
332
- array("error" => "Username not accepted from server",
333
- "smtp_code" => $code,
334
- "smtp_msg" => substr($rply,4));
335
- if($this->do_debug >= 1) {
336
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
337
- }
338
- return false;
339
- }
340
-
341
- // Send encoded password
342
- fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
343
-
344
- $rply = $this->get_lines();
345
- $code = substr($rply,0,3);
346
-
347
- if($code != 235) {
348
- $this->error =
349
- array("error" => "Password not accepted from server",
350
- "smtp_code" => $code,
351
- "smtp_msg" => substr($rply,4));
352
- if($this->do_debug >= 1) {
353
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
354
- }
355
- return false;
356
- }
357
- break;
358
- case 'NTLM':
359
- /*
360
- * ntlm_sasl_client.php
361
- ** Bundled with Permission
362
- **
363
- ** How to telnet in windows: http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx
364
- ** PROTOCOL Documentation http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication
365
- */
366
- require_once 'ntlm_sasl_client.php';
367
- $temp = new stdClass();
368
- $ntlm_client = new ntlm_sasl_client_class;
369
- if(! $ntlm_client->Initialize($temp)){//let's test if every function its available
370
- $this->error = array("error" => $temp->error);
371
- if($this->do_debug >= 1) {
372
- $this->edebug("You need to enable some modules in your php.ini file: " . $this->error["error"] . $this->CRLF);
373
- }
374
- return false;
375
- }
376
- $msg1 = $ntlm_client->TypeMsg1($realm, $workstation);//msg1
377
-
378
- fputs($this->smtp_conn,"AUTH NTLM " . base64_encode($msg1) . $this->CRLF);
379
-
380
- $rply = $this->get_lines();
381
- $code = substr($rply,0,3);
382
-
383
-
384
- if($code != 334) {
385
- $this->error =
386
- array("error" => "AUTH not accepted from server",
387
- "smtp_code" => $code,
388
- "smtp_msg" => substr($rply,4));
389
- if($this->do_debug >= 1) {
390
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF);
391
- }
392
- return false;
393
- }
394
-
395
- $challenge = substr($rply,3);//though 0 based, there is a white space after the 3 digit number....//msg2
396
- $challenge = base64_decode($challenge);
397
- $ntlm_res = $ntlm_client->NTLMResponse(substr($challenge,24,8),$password);
398
- $msg3 = $ntlm_client->TypeMsg3($ntlm_res,$username,$realm,$workstation);//msg3
399
- // Send encoded username
400
- fputs($this->smtp_conn, base64_encode($msg3) . $this->CRLF);
401
-
402
- $rply = $this->get_lines();
403
- $code = substr($rply,0,3);
404
-
405
- if($code != 235) {
406
- $this->error =
407
- array("error" => "Could not authenticate",
408
- "smtp_code" => $code,
409
- "smtp_msg" => substr($rply,4));
410
- if($this->do_debug >= 1) {
411
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF);
412
- }
413
- return false;
414
- }
415
- break;
416
- case 'CRAM-MD5':
417
- // Start authentication
418
- fputs($this->smtp_conn,"AUTH CRAM-MD5" . $this->CRLF);
419
-
420
- $rply = $this->get_lines();
421
- $code = substr($rply,0,3);
422
-
423
- if($code != 334) {
424
- $this->error =
425
- array("error" => "AUTH not accepted from server",
426
- "smtp_code" => $code,
427
- "smtp_msg" => substr($rply,4));
428
- if($this->do_debug >= 1) {
429
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
430
- }
431
- return false;
432
- }
433
-
434
- // Get the challenge
435
- $challenge = base64_decode(substr($rply,4));
436
-
437
- // Build the response
438
- $response = $username . ' ' . $this->hmac($challenge, $password);
439
-
440
- // Send encoded credentials
441
- fputs($this->smtp_conn, base64_encode($response) . $this->CRLF);
442
-
443
- $rply = $this->get_lines();
444
- $code = substr($rply,0,3);
445
-
446
- if($code != 334) {
447
- $this->error =
448
- array("error" => "Credentials not accepted from server",
449
- "smtp_code" => $code,
450
- "smtp_msg" => substr($rply,4));
451
- if($this->do_debug >= 1) {
452
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
453
- }
454
- return false;
455
- }
456
- break;
457
- }
458
- return true;
459
- }
460
-
461
- /**
462
- * Works like hash_hmac('md5', $data, $key) in case that function is not available
463
- * @access private
464
- * @param string $data
465
- * @param string $key
466
- * @return string
467
- */
468
- private function hmac($data, $key) {
469
- if (function_exists('hash_hmac')) {
470
- return hash_hmac('md5', $data, $key);
471
- }
472
-
473
- // The following borrowed from http://php.net/manual/en/function.mhash.php#27225
474
-
475
- // RFC 2104 HMAC implementation for php.
476
- // Creates an md5 HMAC.
477
- // Eliminates the need to install mhash to compute a HMAC
478
- // Hacked by Lance Rushing
479
-
480
- $b = 64; // byte length for md5
481
- if (strlen($key) > $b) {
482
- $key = pack("H*",md5($key));
483
- }
484
- $key = str_pad($key, $b, chr(0x00));
485
- $ipad = str_pad('', $b, chr(0x36));
486
- $opad = str_pad('', $b, chr(0x5c));
487
- $k_ipad = $key ^ $ipad ;
488
- $k_opad = $key ^ $opad;
489
-
490
- return md5($k_opad . pack("H*",md5($k_ipad . $data)));
491
- }
492
-
493
- /**
494
- * Returns true if connected to a server otherwise false
495
- * @access public
496
- * @return bool
497
- */
498
- public function Connected() {
499
- if(!empty($this->smtp_conn)) {
500
- $sock_status = socket_get_status($this->smtp_conn);
501
- if($sock_status["eof"]) {
502
- // the socket is valid but we are not connected
503
- if($this->do_debug >= 1) {
504
- $this->edebug("SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected");
505
- }
506
- $this->Close();
507
- return false;
508
- }
509
- return true; // everything looks good
510
- }
511
- return false;
512
- }
513
-
514
- /**
515
- * Closes the socket and cleans up the state of the class.
516
- * It is not considered good to use this function without
517
- * first trying to use QUIT.
518
- * @access public
519
- * @return void
520
- */
521
- public function Close() {
522
- $this->error = null; // so there is no confusion
523
- $this->helo_rply = null;
524
- if(!empty($this->smtp_conn)) {
525
- // close the connection and cleanup
526
- fclose($this->smtp_conn);
527
- $this->smtp_conn = 0;
528
- }
529
- }
530
-
531
- /////////////////////////////////////////////////
532
- // SMTP COMMANDS
533
- /////////////////////////////////////////////////
534
-
535
- /**
536
- * Issues a data command and sends the msg_data to the server
537
- * finializing the mail transaction. $msg_data is the message
538
- * that is to be send with the headers. Each header needs to be
539
- * on a single line followed by a <CRLF> with the message headers
540
- * and the message body being seperated by and additional <CRLF>.
541
- *
542
- * Implements rfc 821: DATA <CRLF>
543
- *
544
- * SMTP CODE INTERMEDIATE: 354
545
- * [data]
546
- * <CRLF>.<CRLF>
547
- * SMTP CODE SUCCESS: 250
548
- * SMTP CODE FAILURE: 552,554,451,452
549
- * SMTP CODE FAILURE: 451,554
550
- * SMTP CODE ERROR : 500,501,503,421
551
- * @access public
552
- * @param string $msg_data
553
- * @return bool
554
- */
555
- public function Data($msg_data) {
556
- $this->error = null; // so no confusion is caused
557
-
558
- if(!$this->connected()) {
559
- $this->error = array(
560
- "error" => "Called Data() without being connected");
561
- return false;
562
- }
563
-
564
- fputs($this->smtp_conn,"DATA" . $this->CRLF);
565
-
566
- $rply = $this->get_lines();
567
- $code = substr($rply,0,3);
568
-
569
- if($this->do_debug >= 2) {
570
- $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
571
- }
572
-
573
- if($code != 354) {
574
- $this->error =
575
- array("error" => "DATA command not accepted from server",
576
- "smtp_code" => $code,
577
- "smtp_msg" => substr($rply,4));
578
- if($this->do_debug >= 1) {
579
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
580
- }
581
- return false;
582
- }
583
-
584
- /* the server is ready to accept data!
585
- * according to rfc 821 we should not send more than 1000
586
- * including the CRLF
587
- * characters on a single line so we will break the data up
588
- * into lines by \r and/or \n then if needed we will break
589
- * each of those into smaller lines to fit within the limit.
590
- * in addition we will be looking for lines that start with
591
- * a period '.' and append and additional period '.' to that
592
- * line. NOTE: this does not count towards limit.
593
- */
594
-
595
- // normalize the line breaks so we know the explode works
596
- $msg_data = str_replace("\r\n","\n",$msg_data);
597
- $msg_data = str_replace("\r","\n",$msg_data);
598
- $lines = explode("\n",$msg_data);
599
-
600
- /* we need to find a good way to determine is headers are
601
- * in the msg_data or if it is a straight msg body
602
- * currently I am assuming rfc 822 definitions of msg headers
603
- * and if the first field of the first line (':' sperated)
604
- * does not contain a space then it _should_ be a header
605
- * and we can process all lines before a blank "" line as
606
- * headers.
607
- */
608
-
609
- $field = substr($lines[0],0,strpos($lines[0],":"));
610
- $in_headers = false;
611
- if(!empty($field) && !strstr($field," ")) {
612
- $in_headers = true;
613
- }
614
-
615
- $max_line_length = 998; // used below; set here for ease in change
616
-
617
- while(list(,$line) = @each($lines)) {
618
- $lines_out = null;
619
- if($line == "" && $in_headers) {
620
- $in_headers = false;
621
- }
622
- // ok we need to break this line up into several smaller lines
623
- while(strlen($line) > $max_line_length) {
624
- $pos = strrpos(substr($line,0,$max_line_length)," ");
625
-
626
- // Patch to fix DOS attack
627
- if(!$pos) {
628
- $pos = $max_line_length - 1;
629
- $lines_out[] = substr($line,0,$pos);
630
- $line = substr($line,$pos);
631
- } else {
632
- $lines_out[] = substr($line,0,$pos);
633
- $line = substr($line,$pos + 1);
634
- }
635
-
636
- /* if processing headers add a LWSP-char to the front of new line
637
- * rfc 822 on long msg headers
638
- */
639
- if($in_headers) {
640
- $line = "\t" . $line;
641
- }
642
- }
643
- $lines_out[] = $line;
644
-
645
- // send the lines to the server
646
- while(list(,$line_out) = @each($lines_out)) {
647
- if(strlen($line_out) > 0)
648
- {
649
- if(substr($line_out, 0, 1) == ".") {
650
- $line_out = "." . $line_out;
651
- }
652
- }
653
- fputs($this->smtp_conn,$line_out . $this->CRLF);
654
- }
655
- }
656
-
657
- // message data has been sent
658
- fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
659
-
660
- $rply = $this->get_lines();
661
- $code = substr($rply,0,3);
662
-
663
- if($this->do_debug >= 2) {
664
- $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
665
- }
666
-
667
- if($code != 250) {
668
- $this->error =
669
- array("error" => "DATA not accepted from server",
670
- "smtp_code" => $code,
671
- "smtp_msg" => substr($rply,4));
672
- if($this->do_debug >= 1) {
673
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
674
- }
675
- return false;
676
- }
677
- return true;
678
- }
679
-
680
- /**
681
- * Sends the HELO command to the smtp server.
682
- * This makes sure that we and the server are in
683
- * the same known state.
684
- *
685
- * Implements from rfc 821: HELO <SP> <domain> <CRLF>
686
- *
687
- * SMTP CODE SUCCESS: 250
688
- * SMTP CODE ERROR : 500, 501, 504, 421
689
- * @access public
690
- * @param string $host
691
- * @return bool
692
- */
693
- public function Hello($host = '') {
694
- $this->error = null; // so no confusion is caused
695
-
696
- if(!$this->connected()) {
697
- $this->error = array(
698
- "error" => "Called Hello() without being connected");
699
- return false;
700
- }
701
-
702
- // if hostname for HELO was not specified send default
703
- if(empty($host)) {
704
- // determine appropriate default to send to server
705
- $host = "localhost";
706
- }
707
-
708
- // Send extended hello first (RFC 2821)
709
- if(!$this->SendHello("EHLO", $host)) {
710
- if(!$this->SendHello("HELO", $host)) {
711
- return false;
712
- }
713
- }
714
-
715
- return true;
716
- }
717
-
718
- /**
719
- * Sends a HELO/EHLO command.
720
- * @access private
721
- * @param string $hello
722
- * @param string $host
723
- * @return bool
724
- */
725
- private function SendHello($hello, $host) {
726
- fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
727
-
728
- $rply = $this->get_lines();
729
- $code = substr($rply,0,3);
730
-
731
- if($this->do_debug >= 2) {
732
- $this->edebug("SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />');
733
- }
734
-
735
- if($code != 250) {
736
- $this->error =
737
- array("error" => $hello . " not accepted from server",
738
- "smtp_code" => $code,
739
- "smtp_msg" => substr($rply,4));
740
- if($this->do_debug >= 1) {
741
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
742
- }
743
- return false;
744
- }
745
-
746
- $this->helo_rply = $rply;
747
-
748
- return true;
749
- }
750
-
751
- /**
752
- * Starts a mail transaction from the email address specified in
753
- * $from. Returns true if successful or false otherwise. If True
754
- * the mail transaction is started and then one or more Recipient
755
- * commands may be called followed by a Data command.
756
- *
757
- * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
758
- *
759
- * SMTP CODE SUCCESS: 250
760
- * SMTP CODE SUCCESS: 552,451,452
761
- * SMTP CODE SUCCESS: 500,501,421
762
- * @access public
763
- * @param string $from
764
- * @return bool
765
- */
766
- public function Mail($from) {
767
- $this->error = null; // so no confusion is caused
768
-
769
- if(!$this->connected()) {
770
- $this->error = array(
771
- "error" => "Called Mail() without being connected");
772
- return false;
773
- }
774
-
775
- $useVerp = ($this->do_verp ? " XVERP" : "");
776
- fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
777
-
778
- $rply = $this->get_lines();
779
- $code = substr($rply,0,3);
780
-
781
- if($this->do_debug >= 2) {
782
- $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
783
- }
784
-
785
- if($code != 250) {
786
- $this->error =
787
- array("error" => "MAIL not accepted from server",
788
- "smtp_code" => $code,
789
- "smtp_msg" => substr($rply,4));
790
- if($this->do_debug >= 1) {
791
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
792
- }
793
- return false;
794
- }
795
- return true;
796
- }
797
-
798
- /**
799
- * Sends the quit command to the server and then closes the socket
800
- * if there is no error or the $close_on_error argument is true.
801
- *
802
- * Implements from rfc 821: QUIT <CRLF>
803
- *
804
- * SMTP CODE SUCCESS: 221
805
- * SMTP CODE ERROR : 500
806
- * @access public
807
- * @param bool $close_on_error
808
- * @return bool
809
- */
810
- public function Quit($close_on_error = true) {
811
- $this->error = null; // so there is no confusion
812
-
813
- if(!$this->connected()) {
814
- $this->error = array(
815
- "error" => "Called Quit() without being connected");
816
- return false;
817
- }
818
-
819
- // send the quit command to the server
820
- fputs($this->smtp_conn,"quit" . $this->CRLF);
821
-
822
- // get any good-bye messages
823
- $byemsg = $this->get_lines();
824
-
825
- if($this->do_debug >= 2) {
826
- $this->edebug("SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />');
827
- }
828
-
829
- $rval = true;
830
- $e = null;
831
-
832
- $code = substr($byemsg,0,3);
833
- if($code != 221) {
834
- // use e as a tmp var cause Close will overwrite $this->error
835
- $e = array("error" => "SMTP server rejected quit command",
836
- "smtp_code" => $code,
837
- "smtp_rply" => substr($byemsg,4));
838
- $rval = false;
839
- if($this->do_debug >= 1) {
840
- $this->edebug("SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />');
841
- }
842
- }
843
-
844
- if(empty($e) || $close_on_error) {
845
- $this->Close();
846
- }
847
-
848
- return $rval;
849
- }
850
-
851
- /**
852
- * Sends the command RCPT to the SMTP server with the TO: argument of $to.
853
- * Returns true if the recipient was accepted false if it was rejected.
854
- *
855
- * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
856
- *
857
- * SMTP CODE SUCCESS: 250,251
858
- * SMTP CODE FAILURE: 550,551,552,553,450,451,452
859
- * SMTP CODE ERROR : 500,501,503,421
860
- * @access public
861
- * @param string $to
862
- * @return bool
863
- */
864
- public function Recipient($to) {
865
- $this->error = null; // so no confusion is caused
866
-
867
- if(!$this->connected()) {
868
- $this->error = array(
869
- "error" => "Called Recipient() without being connected");
870
- return false;
871
- }
872
-
873
- fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
874
-
875
- $rply = $this->get_lines();
876
- $code = substr($rply,0,3);
877
-
878
- if($this->do_debug >= 2) {
879
- $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
880
- }
881
-
882
- if($code != 250 && $code != 251) {
883
- $this->error =
884
- array("error" => "RCPT not accepted from server",
885
- "smtp_code" => $code,
886
- "smtp_msg" => substr($rply,4));
887
- if($this->do_debug >= 1) {
888
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
889
- }
890
- return false;
891
- }
892
- return true;
893
- }
894
-
895
- /**
896
- * Sends the RSET command to abort and transaction that is
897
- * currently in progress. Returns true if successful false
898
- * otherwise.
899
- *
900
- * Implements rfc 821: RSET <CRLF>
901
- *
902
- * SMTP CODE SUCCESS: 250
903
- * SMTP CODE ERROR : 500,501,504,421
904
- * @access public
905
- * @return bool
906
- */
907
- public function Reset() {
908
- $this->error = null; // so no confusion is caused
909
-
910
- if(!$this->connected()) {
911
- $this->error = array(
912
- "error" => "Called Reset() without being connected");
913
- return false;
914
- }
915
-
916
- fputs($this->smtp_conn,"RSET" . $this->CRLF);
917
-
918
- $rply = $this->get_lines();
919
- $code = substr($rply,0,3);
920
-
921
- if($this->do_debug >= 2) {
922
- $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
923
- }
924
-
925
- if($code != 250) {
926
- $this->error =
927
- array("error" => "RSET failed",
928
- "smtp_code" => $code,
929
- "smtp_msg" => substr($rply,4));
930
- if($this->do_debug >= 1) {
931
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
932
- }
933
- return false;
934
- }
935
-
936
- return true;
937
- }
938
-
939
- /**
940
- * Starts a mail transaction from the email address specified in
941
- * $from. Returns true if successful or false otherwise. If True
942
- * the mail transaction is started and then one or more Recipient
943
- * commands may be called followed by a Data command. This command
944
- * will send the message to the users terminal if they are logged
945
- * in and send them an email.
946
- *
947
- * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
948
- *
949
- * SMTP CODE SUCCESS: 250
950
- * SMTP CODE SUCCESS: 552,451,452
951
- * SMTP CODE SUCCESS: 500,501,502,421
952
- * @access public
953
- * @param string $from
954
- * @return bool
955
- */
956
- public function SendAndMail($from) {
957
- $this->error = null; // so no confusion is caused
958
-
959
- if(!$this->connected()) {
960
- $this->error = array(
961
- "error" => "Called SendAndMail() without being connected");
962
- return false;
963
- }
964
-
965
- fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
966
-
967
- $rply = $this->get_lines();
968
- $code = substr($rply,0,3);
969
-
970
- if($this->do_debug >= 2) {
971
- $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
972
- }
973
-
974
- if($code != 250) {
975
- $this->error =
976
- array("error" => "SAML not accepted from server",
977
- "smtp_code" => $code,
978
- "smtp_msg" => substr($rply,4));
979
- if($this->do_debug >= 1) {
980
- $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
981
- }
982
- return false;
983
- }
984
- return true;
985
- }
986
-
987
- /**
988
- * This is an optional command for SMTP that this class does not
989
- * support. This method is here to make the RFC821 Definition
990
- * complete for this class and __may__ be implimented in the future
991
- *
992
- * Implements from rfc 821: TURN <CRLF>
993
- *
994
- * SMTP CODE SUCCESS: 250
995
- * SMTP CODE FAILURE: 502
996
- * SMTP CODE ERROR : 500, 503
997
- * @access public
998
- * @return bool
999
- */
1000
- public function Turn() {
1001
- $this->error = array("error" => "This method, TURN, of the SMTP ".
1002
- "is not implemented");
1003
- if($this->do_debug >= 1) {
1004
- $this->edebug("SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />');
1005
- }
1006
- return false;
1007
- }
1008
-
1009
- /**
1010
- * Get the current error
1011
- * @access public
1012
- * @return array
1013
- */
1014
- public function getError() {
1015
- return $this->error;
1016
- }
1017
-
1018
- /////////////////////////////////////////////////
1019
- // INTERNAL FUNCTIONS
1020
- /////////////////////////////////////////////////
1021
-
1022
- /**
1023
- * Read in as many lines as possible
1024
- * either before eof or socket timeout occurs on the operation.
1025
- * With SMTP we can tell if we have more lines to read if the
1026
- * 4th character is '-' symbol. If it is a space then we don't
1027
- * need to read anything else.
1028
- * @access private
1029
- * @return string
1030
- */
1031
- private function get_lines() {
1032
- $data = "";
1033
- $endtime = 0;
1034
- /* If for some reason the fp is bad, don't inf loop */
1035
- if (!is_resource($this->smtp_conn)) {
1036
- return $data;
1037
- }
1038
- stream_set_timeout($this->smtp_conn, $this->Timeout);
1039
- if ($this->Timelimit > 0) {
1040
- $endtime = time() + $this->Timelimit;
1041
- }
1042
- while(is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
1043
- $str = @fgets($this->smtp_conn,515);
1044
- if($this->do_debug >= 4) {
1045
- $this->edebug("SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />');
1046
- $this->edebug("SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />');
1047
- }
1048
- $data .= $str;
1049
- if($this->do_debug >= 4) {
1050
- $this->edebug("SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />');
1051
- }
1052
- // if 4th character is a space, we are done reading, break the loop
1053
- if(substr($str,3,1) == " ") { break; }
1054
- // Timed-out? Log and break
1055
- $info = stream_get_meta_data($this->smtp_conn);
1056
- if ($info['timed_out']) {
1057
- if($this->do_debug >= 4) {
1058
- $this->edebug("SMTP -> get_lines(): timed-out (" . $this->Timeout . " seconds) <br />");
1059
- }
1060
- break;
1061
- }
1062
- // Now check if reads took too long
1063
- if ($endtime) {
1064
- if (time() > $endtime) {
1065
- if($this->do_debug >= 4) {
1066
- $this->edebug("SMTP -> get_lines(): timelimit reached (" . $this->Timelimit . " seconds) <br />");
1067
- }
1068
- break;
1069
- }
1070
- }
1071
- }
1072
- return $data;
1073
- }
1074
-
1075
- }