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 */
16class 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 static::setLanguage();
28 }
29
30 /**
31 * Defines the error messages using WordPress' internationalization method.
32 *
33 * @since 6.8.0
34 *
35 * @param string $langcode Optional. Unused. ISO 639-1 2-character language code. Default 'en'.
36 * @param string $lang_path Optional. Unused. Path to the language file directory. Default empty string.
37 * @return true Always returns true.
38 */
39 public static function setLanguage( $langcode = 'en', $lang_path = '' ) {
40 static::$language = array(
41 'authenticate' => __( 'SMTP Error: Could not authenticate.' ),
42 'buggy_php' => sprintf(
43 /* translators: 1: mail.add_x_header. 2: php.ini */
44 __( '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.' ),
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 host entry: ' ),
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 'no_smtputf8' => __( 'Server does not support SMTPUTF8 needed to send to Unicode addresses' ),
90 'imap_recommended' => __( 'Using simplified address parser is not recommended. Install the PHP IMAP extension for full RFC822 parsing.' ),
91 /* translators: %s: $useimap */
92 'deprecated_argument' => sprintf( __( 'Argument %s is deprecated' ), '$useimap' ),
93 );
94
95 return true;
96 }
97}
98