summaryrefslogtreecommitdiffstatshomepage
path: root/src/wp-includes/class-wp-phpmailer.php
blob: c3f9f3088edc125e77eb6140d1cf39e6122e4d02 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
 * WordPress PHPMailer class.
 *
 * @package WordPress
 * @since 6.8.0
 */

/**
 * WordPress PHPMailer class.
 *
 * Overrides the internationalization method in order to use WordPress' instead.
 *
 * @since 6.8.0
 */
class WP_PHPMailer extends PHPMailer\PHPMailer\PHPMailer {

	/**
	 * Constructor.
	 *
	 * @since 6.8.0
	 *
	 * @param bool $exceptions Optional. Whether to throw exceptions for errors. Default false.
	 */
	public function __construct( $exceptions = false ) {
		parent::__construct( $exceptions );
		$this->setLanguage();
	}

	/**
	 * Defines the error messages using WordPress' internationalization method.
	 *
	 * @since 6.8.0
	 *
	 * @param string $langcode  Optional. Unused. ISO 639-1 2-character language code. Default 'en'.
	 * @param string $lang_path Optional. Unused. Path to the language file directory. Default empty string.
	 * @return true Always returns true.
	 */
	public function setLanguage( $langcode = 'en', $lang_path = '' ) {
		$this->language = array(
			'authenticate'         => __( 'SMTP Error: Could not authenticate.' ),
			'buggy_php'            => sprintf(
				/* translators: 1: mail.add_x_header. 2: php.ini */
				__(
					'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.'
				),
				'mail.add_x_header',
				'php.ini'
			),
			'connect_host'         => __( 'SMTP Error: Could not connect to SMTP host.' ),
			'data_not_accepted'    => __( 'SMTP Error: data not accepted.' ),
			'empty_message'        => __( 'Message body empty' ),
			/* translators: There is a space after the colon. */
			'encoding'             => __( 'Unknown encoding: ' ),
			/* translators: There is a space after the colon. */
			'execute'              => __( 'Could not execute: ' ),
			/* translators: There is a space after the colon. */
			'extension_missing'    => __( 'Extension missing: ' ),
			/* translators: There is a space after the colon. */
			'file_access'          => __( 'Could not access file: ' ),
			/* translators: There is a space after the colon. */
			'file_open'            => __( 'File Error: Could not open file: ' ),
			/* translators: There is a space after the colon. */
			'from_failed'          => __( 'The following From address failed: ' ),
			'instantiate'          => __( 'Could not instantiate mail function.' ),
			/* translators: There is a space after the colon. */
			'invalid_address'      => __( 'Invalid address: ' ),
			'invalid_header'       => __( 'Invalid header name or value' ),
			/* translators: There is a space after the colon. */
			'invalid_hostentry'    => __( 'Invalid hostentry: ' ),
			/* translators: There is a space after the colon. */
			'invalid_host'         => __( 'Invalid host: ' ),
			/* translators: There is a space at the beginning. */
			'mailer_not_supported' => __( ' mailer is not supported.' ),
			'provide_address'      => __( 'You must provide at least one recipient email address.' ),
			/* translators: There is a space after the colon. */
			'recipients_failed'    => __( 'SMTP Error: The following recipients failed: ' ),
			/* translators: There is a space after the colon. */
			'signing'              => __( 'Signing Error: ' ),
			/* translators: There is a space after the colon. */
			'smtp_code'            => __( 'SMTP code: ' ),
			/* translators: There is a space after the colon. */
			'smtp_code_ex'         => __( 'Additional SMTP info: ' ),
			'smtp_connect_failed'  => __( 'SMTP connect() failed.' ),
			/* translators: There is a space after the colon. */
			'smtp_detail'          => __( 'Detail: ' ),
			/* translators: There is a space after the colon. */
			'smtp_error'           => __( 'SMTP server error: ' ),
			/* translators: There is a space after the colon. */
			'variable_set'         => __( 'Cannot set or reset variable: ' ),
		);

		return true;
	}
}