PHPMailer\PHPMailer
PHPMailer::setFrom() public WP 1.0
Set the From and FromName properties.
{} Это метод класса: PHPMailer{}
Хуков нет.
Возвращает
true/false.
Использование
$PHPMailer = new PHPMailer(); $PHPMailer->setFrom( $address, $name, $auto );
- $address(строка) (обязательный)
- -
- $name(строка)
- -
- $auto(true/false)
- Whether to also set the Sender address, defaults to true
Код PHPMailer::setFrom() PHPMailer::setFrom WP 5.6.2
public function setFrom($address, $name = '', $auto = true)
{
$address = trim($address);
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
// Don't validate now addresses with IDN. Will be done in send().
$pos = strrpos($address, '@');
if (
(false === $pos)
|| ((!$this->has8bitChars(substr($address, ++$pos)) || !static::idnSupported())
&& !static::validateAddress($address))
) {
$error_message = sprintf(
'%s (From): %s',
$this->lang('invalid_address'),
$address
);
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
throw new Exception($error_message);
}
return false;
}
$this->From = $address;
$this->FromName = $name;
if ($auto && empty($this->Sender)) {
$this->Sender = $address;
}
return true;
}