Abilities
5 days ago
Admin
5 days ago
Compatibility
5 days ago
Helpers
5 days ago
Integrations
5 days ago
Providers
5 days ago
Queue
5 days ago
Reports
5 days ago
Tasks
5 days ago
TestEmail
5 days ago
UsageTracking
5 days ago
WPCLI
5 days ago
AbstractConnection.php
5 days ago
Conflicts.php
5 days ago
Connect.php
5 days ago
Connection.php
5 days ago
ConnectionInterface.php
5 days ago
ConnectionsManager.php
5 days ago
Core.php
5 days ago
DBRepair.php
5 days ago
Debug.php
5 days ago
EmailSendingDebug.php
5 days ago
Geo.php
5 days ago
MailCatcher.php
5 days ago
MailCatcherInterface.php
5 days ago
MailCatcherTrait.php
5 days ago
MailCatcherV6.php
5 days ago
Migration.php
5 days ago
MigrationAbstract.php
5 days ago
Migrations.php
5 days ago
OptimizedEmailSending.php
5 days ago
Options.php
5 days ago
Processor.php
5 days ago
SiteHealth.php
5 days ago
Upgrade.php
5 days ago
Uploads.php
5 days ago
WP.php
5 days ago
WPMailArgs.php
5 days ago
WPMailInitiator.php
5 days ago
MailCatcher.php
62 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPMailSMTP; |
| 4 | |
| 5 | use phpmailerException; |
| 6 | |
| 7 | // Load PHPMailer class, so we can subclass it. |
| 8 | if ( ! class_exists( 'PHPMailer', false ) ) { |
| 9 | require_once ABSPATH . WPINC . '/class-phpmailer.php'; |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Class MailCatcher replaces the \PHPMailer and modifies the email sending logic. |
| 14 | * Thus, we can use other mailers API to do what we need, or stop emails completely. |
| 15 | * |
| 16 | * @since 1.0.0 |
| 17 | */ |
| 18 | class MailCatcher extends \PHPMailer implements MailCatcherInterface { |
| 19 | |
| 20 | use MailCatcherTrait; |
| 21 | |
| 22 | /** |
| 23 | * Returns all custom headers. |
| 24 | * In older versions of \PHPMailer class this method didn't exist. |
| 25 | * As we support WordPress 3.6+ - we need to make sure this method is always present. |
| 26 | * |
| 27 | * @since 1.5.0 |
| 28 | * |
| 29 | * @return array |
| 30 | */ |
| 31 | public function getCustomHeaders() { |
| 32 | |
| 33 | return $this->CustomHeader; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get the PHPMailer line ending. |
| 38 | * |
| 39 | * @since 2.2.0 |
| 40 | * |
| 41 | * @return string |
| 42 | */ |
| 43 | public function get_line_ending() { |
| 44 | |
| 45 | return $this->LE; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Throw PHPMailer exception. |
| 50 | * |
| 51 | * @since 4.0.0 |
| 52 | * |
| 53 | * @param string $error Error message. |
| 54 | * |
| 55 | * @throws phpmailerException PHPMailer exception. |
| 56 | */ |
| 57 | protected function throw_exception( $error ) { |
| 58 | |
| 59 | throw new phpmailerException( $error ); |
| 60 | } |
| 61 | } |
| 62 |