PHPMailer\PHPMailer
PHPMailer::parseSendmailPath
Extract sendmail path and parse to deal with known parameters.
Method of the class: PHPMailer{}
No Hooks.
Returns
String. The sendmail path without the known parameters
Usage
// private - for code of main (parent) class only $result = $this->parseSendmailPath( $sendmailPath );
- $sendmailPath(string) (required)
- The sendmail path as set in php.ini.
PHPMailer::parseSendmailPath() PHPMailer::parseSendmailPath code WP 7.0
private function parseSendmailPath($sendmailPath)
{
$sendmailPath = trim((string)$sendmailPath);
if ($sendmailPath === '') {
return $sendmailPath;
}
$parts = preg_split('/\s+/', $sendmailPath);
if (empty($parts)) {
return $sendmailPath;
}
$command = array_shift($parts);
$remainder = [];
// Parse only -t, -i, -oi and -f parameters.
for ($i = 0; $i < count($parts); ++$i) {
$part = $parts[$i];
if (preg_match('/^-(i|oi|t)$/', $part, $matches)) {
continue;
}
if (preg_match('/^-f(.*)$/', $part, $matches)) {
$address = $matches[1];
if ($address === '' && isset($parts[$i + 1]) && strpos($parts[$i + 1], '-') !== 0) {
$address = $parts[++$i];
}
$this->Sender = $address;
continue;
}
$remainder[] = $part;
}
// The params that are not parsed are added back to the command.
if (!empty($remainder)) {
$command .= ' ' . implode(' ', $remainder);
}
return $command;
}