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
MailCatcherV6.php
67 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPMailSMTP; |
| 4 | |
| 5 | use PHPMailer\PHPMailer\Exception; |
| 6 | |
| 7 | /** |
| 8 | * Class MailCatcher replaces the \PHPMailer\PHPMailer\PHPMailer introduced in WP 5.5 and |
| 9 | * modifies the email sending logic. Thus, we can use other mailers API to do what we need, or stop emails completely. |
| 10 | * |
| 11 | * @since 2.2.0 |
| 12 | */ |
| 13 | class MailCatcherV6 extends \PHPMailer\PHPMailer\PHPMailer implements MailCatcherInterface { |
| 14 | |
| 15 | use MailCatcherTrait; |
| 16 | |
| 17 | /** |
| 18 | * Callback Action function name. |
| 19 | * |
| 20 | * The function that handles the result of the send email action. |
| 21 | * It is called out by send() for each email sent. |
| 22 | * |
| 23 | * @since 2.2.0 |
| 24 | * |
| 25 | * @var string |
| 26 | */ |
| 27 | public $action_function = '\WPMailSMTP\Processor::send_callback'; |
| 28 | |
| 29 | /** |
| 30 | * Which validator to use by default when validating email addresses. |
| 31 | * We are using built-in WordPress function `is_email` to validate the email address. |
| 32 | * |
| 33 | * @see PHPMailer::validateAddress() |
| 34 | * |
| 35 | * @since 3.6.0 |
| 36 | * |
| 37 | * @var string|callable |
| 38 | */ |
| 39 | public static $validator = [ Processor::class, 'is_email_callback' ]; |
| 40 | |
| 41 | /** |
| 42 | * Get the PHPMailer line ending. |
| 43 | * |
| 44 | * @since 2.2.0 |
| 45 | * |
| 46 | * @return string |
| 47 | */ |
| 48 | public function get_line_ending() { |
| 49 | |
| 50 | return static::$LE; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Throw PHPMailer exception. |
| 55 | * |
| 56 | * @since 4.0.0 |
| 57 | * |
| 58 | * @param string $error Error message. |
| 59 | * |
| 60 | * @throws Exception PHPMailer exception. |
| 61 | */ |
| 62 | protected function throw_exception( $error ) { |
| 63 | |
| 64 | throw new Exception( $error ); |
| 65 | } |
| 66 | } |
| 67 |