@@ -58,44 +58,44 @@ discard block |
||
| 58 | 58 | private $sender = "[email protected]"; |
| 59 | 59 | |
| 60 | 60 | // some smtp response codes |
| 61 | - const SMTP_CONNECT_SUCCESS = 220; |
|
| 62 | - const SMTP_QUIT_SUCCESS = 221; |
|
| 63 | - const SMTP_GENERIC_SUCCESS = 250; |
|
| 64 | - const SMTP_USER_NOT_LOCAL = 251; |
|
| 65 | - const SMTP_CANNOT_VRFY = 252; |
|
| 66 | - const SMTP_SERVICE_UNAVAILABLE = 421; |
|
| 67 | - // 450 Requested mail action not taken: mailbox unavailable (e.g., |
|
| 68 | - // mailbox busy or temporarily blocked for policy reasons) |
|
| 69 | - const SMTP_MAIL_ACTION_NOT_TAKEN = 450; |
|
| 70 | - // 451 Requested action aborted: local error in processing |
|
| 71 | - const SMTP_MAIL_ACTION_ABORTED = 451; |
|
| 72 | - // 452 Requested action not taken: insufficient system storage |
|
| 73 | - const SMTP_REQUESTED_ACTION_NOT_TAKEN = 452; |
|
| 74 | - // 500 Syntax error (may be due to a denied command) |
|
| 75 | - const SMTP_SYNTAX_ERROR = 500; |
|
| 76 | - // 502 Comment not implemented |
|
| 77 | - const SMTP_NOT_IMPLEMENTED = 502; |
|
| 78 | - // 503 Bad sequence of commands (may be due to a denied command) |
|
| 79 | - const SMTP_BAD_SEQUENCE = 503; |
|
| 80 | - // 550 Requested action not taken: mailbox unavailable (e.g., mailbox |
|
| 81 | - // not found, no access, or command rejected for policy reasons) |
|
| 82 | - const SMTP_MBOX_UNAVAILABLE = 550; |
|
| 83 | - const SMTP_USER_NOT_LOCAL_FORWARD = 551; |
|
| 84 | - // 552 Requested mail action aborted: exceeded storage allocation |
|
| 85 | - const SMTP_EXCEEDED_STORAGE_ALLOCAION = 552; |
|
| 86 | - //553 Requested action not taken: mailbox name not allowed (e.g., |
|
| 87 | - //mailbox syntax incorrect) |
|
| 88 | - const SMTP_MBOX_NAME_NOT_ALLOWED = 553; |
|
| 89 | - // 554 Seen this from hotmail MTAs, in response to RSET :( |
|
| 90 | - const SMTP_TRANSACTION_FAILED = 554; |
|
| 61 | + const SMTP_CONNECT_SUCCESS = 220; |
|
| 62 | + const SMTP_QUIT_SUCCESS = 221; |
|
| 63 | + const SMTP_GENERIC_SUCCESS = 250; |
|
| 64 | + const SMTP_USER_NOT_LOCAL = 251; |
|
| 65 | + const SMTP_CANNOT_VRFY = 252; |
|
| 66 | + const SMTP_SERVICE_UNAVAILABLE = 421; |
|
| 67 | + // 450 Requested mail action not taken: mailbox unavailable (e.g., |
|
| 68 | + // mailbox busy or temporarily blocked for policy reasons) |
|
| 69 | + const SMTP_MAIL_ACTION_NOT_TAKEN = 450; |
|
| 70 | + // 451 Requested action aborted: local error in processing |
|
| 71 | + const SMTP_MAIL_ACTION_ABORTED = 451; |
|
| 72 | + // 452 Requested action not taken: insufficient system storage |
|
| 73 | + const SMTP_REQUESTED_ACTION_NOT_TAKEN = 452; |
|
| 74 | + // 500 Syntax error (may be due to a denied command) |
|
| 75 | + const SMTP_SYNTAX_ERROR = 500; |
|
| 76 | + // 502 Comment not implemented |
|
| 77 | + const SMTP_NOT_IMPLEMENTED = 502; |
|
| 78 | + // 503 Bad sequence of commands (may be due to a denied command) |
|
| 79 | + const SMTP_BAD_SEQUENCE = 503; |
|
| 80 | + // 550 Requested action not taken: mailbox unavailable (e.g., mailbox |
|
| 81 | + // not found, no access, or command rejected for policy reasons) |
|
| 82 | + const SMTP_MBOX_UNAVAILABLE = 550; |
|
| 83 | + const SMTP_USER_NOT_LOCAL_FORWARD = 551; |
|
| 84 | + // 552 Requested mail action aborted: exceeded storage allocation |
|
| 85 | + const SMTP_EXCEEDED_STORAGE_ALLOCAION = 552; |
|
| 86 | + //553 Requested action not taken: mailbox name not allowed (e.g., |
|
| 87 | + //mailbox syntax incorrect) |
|
| 88 | + const SMTP_MBOX_NAME_NOT_ALLOWED = 553; |
|
| 89 | + // 554 Seen this from hotmail MTAs, in response to RSET :( |
|
| 90 | + const SMTP_TRANSACTION_FAILED = 554; |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * @param array $domains List of SMTP domains |
|
| 94 | - * @param boolean $sender Set sender of STMP command |
|
| 95 | - * @param integer $timeout Timeout of the stream |
|
| 96 | - * |
|
| 97 | - * @throws SmtpCheckerException when all domain not valid |
|
| 98 | - */ |
|
| 92 | + /** |
|
| 93 | + * @param array $domains List of SMTP domains |
|
| 94 | + * @param boolean $sender Set sender of STMP command |
|
| 95 | + * @param integer $timeout Timeout of the stream |
|
| 96 | + * |
|
| 97 | + * @throws SmtpCheckerException when all domain not valid |
|
| 98 | + */ |
|
| 99 | 99 | function __construct(MxInterface $domains, $sender = "", int $timeout = 10) |
| 100 | 100 | { |
| 101 | 101 | foreach ($domains->getRecordMx() as $domain) { |
@@ -120,46 +120,46 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | - * Sets the The sender of SMTP check email. |
|
| 124 | - * |
|
| 125 | - * @param string $sender the sender |
|
| 126 | - * |
|
| 127 | - * @return void |
|
| 128 | - */ |
|
| 129 | - private function setSender($sender) |
|
| 130 | - { |
|
| 131 | - if (!filter_var($sender, FILTER_VALIDATE_EMAIL)) { |
|
| 123 | + * Sets the The sender of SMTP check email. |
|
| 124 | + * |
|
| 125 | + * @param string $sender the sender |
|
| 126 | + * |
|
| 127 | + * @return void |
|
| 128 | + */ |
|
| 129 | + private function setSender($sender) |
|
| 130 | + { |
|
| 131 | + if (!filter_var($sender, FILTER_VALIDATE_EMAIL)) { |
|
| 132 | 132 | throw new SmtpCheckerException("Email Sender not valid"); |
| 133 | 133 | } |
| 134 | 134 | $this->sender = $sender; |
| 135 | 135 | |
| 136 | - } |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | - * Gets the value of sender. |
|
| 140 | - * |
|
| 141 | - * @return string |
|
| 142 | - */ |
|
| 139 | + * Gets the value of sender. |
|
| 140 | + * |
|
| 141 | + * @return string |
|
| 142 | + */ |
|
| 143 | 143 | private function getSender() |
| 144 | 144 | { |
| 145 | 145 | return $this->sender; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
| 149 | - * Gets the value of domain. |
|
| 150 | - * |
|
| 151 | - * @return array |
|
| 152 | - */ |
|
| 149 | + * Gets the value of domain. |
|
| 150 | + * |
|
| 151 | + * @return array |
|
| 152 | + */ |
|
| 153 | 153 | private function getDomain() |
| 154 | 154 | { |
| 155 | 155 | return $this->domain; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | - * Gets the value of getDomain in object. |
|
| 160 | - * |
|
| 161 | - * @return object |
|
| 162 | - */ |
|
| 159 | + * Gets the value of getDomain in object. |
|
| 160 | + * |
|
| 161 | + * @return object |
|
| 162 | + */ |
|
| 163 | 163 | private function getDomainObj() |
| 164 | 164 | { |
| 165 | 165 | return (object) $this->getDomain(); |
@@ -287,67 +287,67 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - /** |
|
| 291 | - * Gets the value of code. |
|
| 292 | - * |
|
| 293 | - * @return integer |
|
| 294 | - */ |
|
| 295 | - public function getCode() |
|
| 296 | - { |
|
| 297 | - return (int) $this->code; |
|
| 298 | - } |
|
| 290 | + /** |
|
| 291 | + * Gets the value of code. |
|
| 292 | + * |
|
| 293 | + * @return integer |
|
| 294 | + */ |
|
| 295 | + public function getCode() |
|
| 296 | + { |
|
| 297 | + return (int) $this->code; |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | - /** |
|
| 301 | - * Gets the value of isValid. |
|
| 302 | - * |
|
| 303 | - * @return boolean |
|
| 304 | - */ |
|
| 305 | - public function isValid() |
|
| 306 | - { |
|
| 307 | - return $this->isValid; |
|
| 308 | - } |
|
| 300 | + /** |
|
| 301 | + * Gets the value of isValid. |
|
| 302 | + * |
|
| 303 | + * @return boolean |
|
| 304 | + */ |
|
| 305 | + public function isValid() |
|
| 306 | + { |
|
| 307 | + return $this->isValid; |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - /** |
|
| 311 | - * Gets the value of debug. |
|
| 312 | - * |
|
| 313 | - * @return array |
|
| 314 | - */ |
|
| 315 | - public function getDebug() |
|
| 316 | - { |
|
| 317 | - return $this->debug; |
|
| 318 | - } |
|
| 310 | + /** |
|
| 311 | + * Gets the value of debug. |
|
| 312 | + * |
|
| 313 | + * @return array |
|
| 314 | + */ |
|
| 315 | + public function getDebug() |
|
| 316 | + { |
|
| 317 | + return $this->debug; |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - /** |
|
| 321 | - * Gets the value of message. |
|
| 322 | - * |
|
| 323 | - * @return string |
|
| 324 | - */ |
|
| 325 | - public function getMessage() |
|
| 326 | - { |
|
| 327 | - $code = $this->getCode(); |
|
| 328 | - $messages = [ |
|
| 329 | - self::SMTP_CONNECT_SUCCESS => "SMTP connect Success", |
|
| 330 | - self::SMTP_QUIT_SUCCESS => "Quit Success", |
|
| 331 | - self::SMTP_GENERIC_SUCCESS => "SMTP Generic Success", |
|
| 332 | - self::SMTP_USER_NOT_LOCAL => "SMTP User not local", |
|
| 333 | - self::SMTP_CANNOT_VRFY => "SMTP Cannot VRFY user", |
|
| 334 | - self::SMTP_SERVICE_UNAVAILABLE => "SMTP Service not available", |
|
| 335 | - self::SMTP_MAIL_ACTION_NOT_TAKEN => "SMTP mailbox busy or temporarily blocked for policy reasons", |
|
| 336 | - self::SMTP_MAIL_ACTION_ABORTED => "SMTP Requested action aborted: local error in processing", |
|
| 337 | - self::SMTP_REQUESTED_ACTION_NOT_TAKEN => "SMTP Requested action not taken: insufficient system storage", |
|
| 338 | - self::SMTP_SYNTAX_ERROR => "SMTP Syntax error, command unrecognized", |
|
| 339 | - self::SMTP_NOT_IMPLEMENTED => "SMTP Command not implemented", |
|
| 340 | - self::SMTP_BAD_SEQUENCE => "SMTP Bad sequence of commands", |
|
| 341 | - self::SMTP_MBOX_UNAVAILABLE => "SMTP Requested action not taken: mailbox unavailable", |
|
| 342 | - self::SMTP_USER_NOT_LOCAL_FORWARD => "SMTP User not local", |
|
| 343 | - self::SMTP_EXCEEDED_STORAGE_ALLOCAION => "SMTP Requested mail action aborted: exceeded storage allocation", |
|
| 344 | - self::SMTP_MBOX_NAME_NOT_ALLOWED => "Requested action not taken: mailbox name not allowed", |
|
| 345 | - self::SMTP_TRANSACTION_FAILED => "SMTP Transaction failed" |
|
| 346 | - ]; |
|
| 320 | + /** |
|
| 321 | + * Gets the value of message. |
|
| 322 | + * |
|
| 323 | + * @return string |
|
| 324 | + */ |
|
| 325 | + public function getMessage() |
|
| 326 | + { |
|
| 327 | + $code = $this->getCode(); |
|
| 328 | + $messages = [ |
|
| 329 | + self::SMTP_CONNECT_SUCCESS => "SMTP connect Success", |
|
| 330 | + self::SMTP_QUIT_SUCCESS => "Quit Success", |
|
| 331 | + self::SMTP_GENERIC_SUCCESS => "SMTP Generic Success", |
|
| 332 | + self::SMTP_USER_NOT_LOCAL => "SMTP User not local", |
|
| 333 | + self::SMTP_CANNOT_VRFY => "SMTP Cannot VRFY user", |
|
| 334 | + self::SMTP_SERVICE_UNAVAILABLE => "SMTP Service not available", |
|
| 335 | + self::SMTP_MAIL_ACTION_NOT_TAKEN => "SMTP mailbox busy or temporarily blocked for policy reasons", |
|
| 336 | + self::SMTP_MAIL_ACTION_ABORTED => "SMTP Requested action aborted: local error in processing", |
|
| 337 | + self::SMTP_REQUESTED_ACTION_NOT_TAKEN => "SMTP Requested action not taken: insufficient system storage", |
|
| 338 | + self::SMTP_SYNTAX_ERROR => "SMTP Syntax error, command unrecognized", |
|
| 339 | + self::SMTP_NOT_IMPLEMENTED => "SMTP Command not implemented", |
|
| 340 | + self::SMTP_BAD_SEQUENCE => "SMTP Bad sequence of commands", |
|
| 341 | + self::SMTP_MBOX_UNAVAILABLE => "SMTP Requested action not taken: mailbox unavailable", |
|
| 342 | + self::SMTP_USER_NOT_LOCAL_FORWARD => "SMTP User not local", |
|
| 343 | + self::SMTP_EXCEEDED_STORAGE_ALLOCAION => "SMTP Requested mail action aborted: exceeded storage allocation", |
|
| 344 | + self::SMTP_MBOX_NAME_NOT_ALLOWED => "Requested action not taken: mailbox name not allowed", |
|
| 345 | + self::SMTP_TRANSACTION_FAILED => "SMTP Transaction failed" |
|
| 346 | + ]; |
|
| 347 | 347 | |
| 348 | - return |
|
| 349 | - (array_key_exists($code, $messages)) |
|
| 350 | - ? $messages[$code] |
|
| 351 | - : "Unknown message from SMTP"; |
|
| 352 | - } |
|
| 348 | + return |
|
| 349 | + (array_key_exists($code, $messages)) |
|
| 350 | + ? $messages[$code] |
|
| 351 | + : "Unknown message from SMTP"; |
|
| 352 | + } |
|
| 353 | 353 | } |
| 354 | 354 | \ No newline at end of file |