|
1 <?php |
|
2 /** |
|
3 * WordPress PHPMailer class. |
|
4 * |
|
5 * @package WordPress |
|
6 * @since 6.8.0 |
|
7 */ |
|
8 |
|
9 /** |
|
10 * WordPress PHPMailer class. |
|
11 * |
|
12 * Overrides the internationalization method in order to use WordPress' instead. |
|
13 * |
|
14 * @since 6.8.0 |
|
15 */ |
|
16 class WP_PHPMailer extends PHPMailer\PHPMailer\PHPMailer { |
|
17 |
|
18 /** |
|
19 * Constructor. |
|
20 * |
|
21 * @since 6.8.0 |
|
22 * |
|
23 * @param bool $exceptions Optional. Whether to throw exceptions for errors. Default false. |
|
24 */ |
|
25 public function __construct( $exceptions = false ) { |
|
26 parent::__construct( $exceptions ); |
|
27 $this->SetLanguage(); |
|
28 } |
|
29 |
|
30 /** |
|
31 * Defines the error messages using WordPress' internationalization method. |
|
32 * |
|
33 * @since 6.8.0 |
|
34 * |
|
35 * @return true Always returns true. |
|
36 */ |
|
37 public function SetLanguage( $langcode = 'en', $lang_path = '' ) { |
|
38 $error_strings = array( |
|
39 'authenticate' => __( 'SMTP Error: Could not authenticate.' ), |
|
40 'buggy_php' => sprintf( |
|
41 /* translators: 1: mail.add_x_header. 2: php.ini */ |
|
42 __( |
|
43 'Your version of PHP is affected by a bug that may result in corrupted messages. To fix it, switch to sending using SMTP, disable the %1$s option in your %2$s, or switch to MacOS or Linux, or upgrade your PHP version.' |
|
44 ), |
|
45 'mail.add_x_header', |
|
46 'php.ini' |
|
47 ), |
|
48 'connect_host' => __( 'SMTP Error: Could not connect to SMTP host.' ), |
|
49 'data_not_accepted' => __( 'SMTP Error: data not accepted.' ), |
|
50 'empty_message' => __( 'Message body empty' ), |
|
51 /* translators: There is a space after the colon. */ |
|
52 'encoding' => __( 'Unknown encoding: ' ), |
|
53 /* translators: There is a space after the colon. */ |
|
54 'execute' => __( 'Could not execute: ' ), |
|
55 /* translators: There is a space after the colon. */ |
|
56 'extension_missing' => __( 'Extension missing: ' ), |
|
57 /* translators: There is a space after the colon. */ |
|
58 'file_access' => __( 'Could not access file: ' ), |
|
59 /* translators: There is a space after the colon. */ |
|
60 'file_open' => __( 'File Error: Could not open file: ' ), |
|
61 /* translators: There is a space after the colon. */ |
|
62 'from_failed' => __( 'The following From address failed: ' ), |
|
63 'instantiate' => __( 'Could not instantiate mail function.' ), |
|
64 /* translators: There is a space after the colon. */ |
|
65 'invalid_address' => __( 'Invalid address: ' ), |
|
66 'invalid_header' => __( 'Invalid header name or value' ), |
|
67 /* translators: There is a space after the colon. */ |
|
68 'invalid_hostentry' => __( 'Invalid hostentry: ' ), |
|
69 /* translators: There is a space after the colon. */ |
|
70 'invalid_host' => __( 'Invalid host: ' ), |
|
71 /* translators: There is a space at the beginning. */ |
|
72 'mailer_not_supported' => __( ' mailer is not supported.' ), |
|
73 'provide_address' => __( 'You must provide at least one recipient email address.' ), |
|
74 /* translators: There is a space after the colon. */ |
|
75 'recipients_failed' => __( 'SMTP Error: The following recipients failed: ' ), |
|
76 /* translators: There is a space after the colon. */ |
|
77 'signing' => __( 'Signing Error: ' ), |
|
78 /* translators: There is a space after the colon. */ |
|
79 'smtp_code' => __( 'SMTP code: ' ), |
|
80 /* translators: There is a space after the colon. */ |
|
81 'smtp_code_ex' => __( 'Additional SMTP info: ' ), |
|
82 'smtp_connect_failed' => __( 'SMTP connect() failed.' ), |
|
83 /* translators: There is a space after the colon. */ |
|
84 'smtp_detail' => __( 'Detail: ' ), |
|
85 /* translators: There is a space after the colon. */ |
|
86 'smtp_error' => __( 'SMTP server error: ' ), |
|
87 /* translators: There is a space after the colon. */ |
|
88 'variable_set' => __( 'Cannot set or reset variable: ' ), |
|
89 ); |
|
90 $this->language = $error_strings; |
|
91 return true; |
|
92 } |
|
93 } |