PHPMailer\PHPMailer
PHPMailer::setFrom()
Set the From and FromName properties.
Method of the class: PHPMailer{}
No Hooks.
Return
true|false
.
Usage
$PHPMailer = new PHPMailer(); $PHPMailer->setFrom( $address, $name, $auto );
- $address(string) (required)
- -
- $name(string)
- -
Default: '' - $auto(true|false)
- Whether to also set the Sender address, defaults to true
Default: true
PHPMailer::setFrom() PHPMailer::setFrom code WP 6.6.1
public function setFrom($address, $name = '', $auto = true) { $address = trim((string)$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; }