Changeset 57137
- Timestamp:
- 11/26/2023 07:25:50 PM (11 months ago)
- Location:
- trunk/src/wp-includes/PHPMailer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/PHPMailer/PHPMailer.php
r56484 r57137 359 359 360 360 /** 361 * SMTP SMTPXClient command attibutes 362 * 363 * @var array 364 */ 365 protected $SMTPXClient = []; 366 367 /** 361 368 * An implementation of the PHPMailer OAuthTokenProvider interface. 362 369 * … … 751 758 * @var string 752 759 */ 753 const VERSION = '6. 8.1';760 const VERSION = '6.9.1'; 754 761 755 762 /** … … 1574 1581 //Validate From, Sender, and ConfirmReadingTo addresses 1575 1582 foreach (['From', 'Sender', 'ConfirmReadingTo'] as $address_kind) { 1583 if ($this->{$address_kind} === null) { 1584 $this->{$address_kind} = ''; 1585 continue; 1586 } 1576 1587 $this->{$address_kind} = trim($this->{$address_kind}); 1577 1588 if (empty($this->{$address_kind})) { … … 2001 2012 2002 2013 /** 2014 * Provide SMTP XCLIENT attributes 2015 * 2016 * @param string $name Attribute name 2017 * @param ?string $value Attribute value 2018 * 2019 * @return bool 2020 */ 2021 public function setSMTPXclientAttribute($name, $value) 2022 { 2023 if (!in_array($name, SMTP::$xclient_allowed_attributes)) { 2024 return false; 2025 } 2026 if (isset($this->SMTPXClient[$name]) && $value === null) { 2027 unset($this->SMTPXClient[$name]); 2028 } elseif ($value !== null) { 2029 $this->SMTPXClient[$name] = $value; 2030 } 2031 2032 return true; 2033 } 2034 2035 /** 2036 * Get SMTP XCLIENT attributes 2037 * 2038 * @return array 2039 */ 2040 public function getSMTPXclientAttributes() 2041 { 2042 return $this->SMTPXClient; 2043 } 2044 2045 /** 2003 2046 * Send mail via SMTP. 2004 2047 * Returns false if there is a bad MAIL FROM, RCPT, or DATA input. … … 2027 2070 } else { 2028 2071 $smtp_from = $this->Sender; 2072 } 2073 if (count($this->SMTPXClient)) { 2074 $this->smtp->xclient($this->SMTPXClient); 2029 2075 } 2030 2076 if (!$this->smtp->mail($smtp_from)) { … … 2190 2236 //Automatically enable TLS encryption if: 2191 2237 //* it's not disabled 2238 //* we are not connecting to localhost 2192 2239 //* we have openssl extension 2193 2240 //* we are not already using SSL 2194 2241 //* the server offers STARTTLS 2195 if ($this->SMTPAutoTLS && $sslext && 'ssl' !== $secure && $this->smtp->getServerExt('STARTTLS')) { 2242 if ( 2243 $this->SMTPAutoTLS && 2244 $this->Host !== 'localhost' && 2245 $sslext && 2246 $secure !== 'ssl' && 2247 $this->smtp->getServerExt('STARTTLS') 2248 ) { 2196 2249 $tls = true; 2197 2250 } … … 4051 4104 4052 4105 /** 4106 * Clear a specific custom header by name or name and value. 4107 * $name value can be overloaded to contain 4108 * both header name and value (name:value). 4109 * 4110 * @param string $name Custom header name 4111 * @param string|null $value Header value 4112 * 4113 * @return bool True if a header was replaced successfully 4114 */ 4115 public function clearCustomHeader($name, $value = null) 4116 { 4117 if (null === $value && strpos($name, ':') !== false) { 4118 //Value passed in as name:value 4119 list($name, $value) = explode(':', $name, 2); 4120 } 4121 $name = trim($name); 4122 $value = (null === $value) ? null : trim($value); 4123 4124 foreach ($this->CustomHeader as $k => $pair) { 4125 if ($pair[0] == $name) { 4126 // We remove the header if the value is not provided or it matches. 4127 if (null === $value || $pair[1] == $value) { 4128 unset($this->CustomHeader[$k]); 4129 } 4130 } 4131 } 4132 4133 return true; 4134 } 4135 4136 /** 4137 * Replace a custom header. 4138 * $name value can be overloaded to contain 4139 * both header name and value (name:value). 4140 * 4141 * @param string $name Custom header name 4142 * @param string|null $value Header value 4143 * 4144 * @return bool True if a header was replaced successfully 4145 * @throws Exception 4146 */ 4147 public function replaceCustomHeader($name, $value = null) 4148 { 4149 if (null === $value && strpos($name, ':') !== false) { 4150 //Value passed in as name:value 4151 list($name, $value) = explode(':', $name, 2); 4152 } 4153 $name = trim($name); 4154 $value = (null === $value) ? '' : trim($value); 4155 4156 $replaced = false; 4157 foreach ($this->CustomHeader as $k => $pair) { 4158 if ($pair[0] == $name) { 4159 if ($replaced) { 4160 unset($this->CustomHeader[$k]); 4161 continue; 4162 } 4163 if (strpbrk($name . $value, "\r\n") !== false) { 4164 if ($this->exceptions) { 4165 throw new Exception($this->lang('invalid_header')); 4166 } 4167 4168 return false; 4169 } 4170 $this->CustomHeader[$k] = [$name, $value]; 4171 $replaced = true; 4172 } 4173 } 4174 4175 return true; 4176 } 4177 4178 /** 4053 4179 * Add an error message to the error container. 4054 4180 * -
trunk/src/wp-includes/PHPMailer/SMTP.php
r56484 r57137 36 36 * @var string 37 37 */ 38 const VERSION = '6. 8.1';38 const VERSION = '6.9.1'; 39 39 40 40 /** … … 197 197 'ZoneMTA' => '/[\d]{3} Message queued as (.*)/', 198 198 'Mailjet' => '/[\d]{3} OK queued as (.*)/', 199 ]; 200 201 /** 202 * Allowed SMTP XCLIENT attributes. 203 * Must be allowed by the SMTP server. EHLO response is not checked. 204 * 205 * @see https://www.postfix.org/XCLIENT_README.html 206 * 207 * @var array 208 */ 209 public static $xclient_allowed_attributes = [ 210 'NAME', 'ADDR', 'PORT', 'PROTO', 'HELO', 'LOGIN', 'DESTADDR', 'DESTPORT' 199 211 ]; 200 212 … … 973 985 974 986 /** 987 * Send SMTP XCLIENT command to server and check its return code. 988 * 989 * @return bool True on success 990 */ 991 public function xclient(array $vars) 992 { 993 $xclient_options = ""; 994 foreach ($vars as $key => $value) { 995 if (in_array($key, SMTP::$xclient_allowed_attributes)) { 996 $xclient_options .= " {$key}={$value}"; 997 } 998 } 999 if (!$xclient_options) { 1000 return true; 1001 } 1002 return $this->sendCommand('XCLIENT', 'XCLIENT' . $xclient_options, 250); 1003 } 1004 1005 /** 975 1006 * Send an SMTP RSET command. 976 1007 * Abort any transaction that is currently in progress.
Note: See TracChangeset
for help on using the changeset viewer.