Admin
1 year ago
Compatibility
1 year ago
Helpers
1 year ago
Providers
1 year ago
Queue
1 year ago
Reports
1 year ago
Tasks
1 year ago
UsageTracking
1 year ago
AbstractConnection.php
1 year ago
Conflicts.php
1 year ago
Connect.php
1 year ago
Connection.php
1 year ago
ConnectionInterface.php
1 year ago
ConnectionsManager.php
1 year ago
Core.php
1 year ago
DBRepair.php
1 year ago
Debug.php
1 year ago
Geo.php
1 year ago
MailCatcher.php
1 year ago
MailCatcherInterface.php
1 year ago
MailCatcherTrait.php
1 year ago
MailCatcherV6.php
1 year ago
Migration.php
1 year ago
MigrationAbstract.php
1 year ago
Migrations.php
1 year ago
OptimizedEmailSending.php
1 year ago
Options.php
1 year ago
Processor.php
1 year ago
SiteHealth.php
1 year ago
Upgrade.php
1 year ago
Uploads.php
1 year ago
WP.php
1 year ago
WPMailArgs.php
1 year ago
WPMailInitiator.php
1 year ago
MailCatcher.php
74 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 | * Callback Action function name. |
| 24 | * |
| 25 | * The function that handles the result of the send email action. |
| 26 | * It is called out by send() for each email sent. |
| 27 | * |
| 28 | * @since 1.3.0 |
| 29 | * |
| 30 | * @var string |
| 31 | */ |
| 32 | public $action_function = '\WPMailSMTP\Processor::send_callback'; |
| 33 | |
| 34 | /** |
| 35 | * Returns all custom headers. |
| 36 | * In older versions of \PHPMailer class this method didn't exist. |
| 37 | * As we support WordPress 3.6+ - we need to make sure this method is always present. |
| 38 | * |
| 39 | * @since 1.5.0 |
| 40 | * |
| 41 | * @return array |
| 42 | */ |
| 43 | public function getCustomHeaders() { |
| 44 | |
| 45 | return $this->CustomHeader; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Get the PHPMailer line ending. |
| 50 | * |
| 51 | * @since 2.2.0 |
| 52 | * |
| 53 | * @return string |
| 54 | */ |
| 55 | public function get_line_ending() { |
| 56 | |
| 57 | return $this->LE; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Throw PHPMailer exception. |
| 62 | * |
| 63 | * @since 4.0.0 |
| 64 | * |
| 65 | * @param string $error Error message. |
| 66 | * |
| 67 | * @throws phpmailerException PHPMailer exception. |
| 68 | */ |
| 69 | protected function throw_exception( $error ) { |
| 70 | |
| 71 | throw new phpmailerException( $error ); |
| 72 | } |
| 73 | } |
| 74 |