选择语言 :

 Core_Email::from

Set FROM

Email Core_Email::from( string $from [, string $name = empty ] )

参数列表

参数 类型 描述 默认值
$from string
$name string empty
返回值
  • Email
File: ./core/classes/email.class.php
public function from($from, $name = '')
{
    if (preg_match('/\<(.*)\>/', $from, $match))
    {
        $from = $match[1];
    }

    if ($this->validate)
    {
        $this->validate_email($this->_str_to_array($from));
    }

    // prepare the display name
    if ($name !== '')
    {
        // only use Q encoding if there are characters that would require it
        if ( ! preg_match('/[\200-\377]/', $name))
        {
            // add slashes for non-printing characters, slashes, and double quotes, and surround it in double quotes
            $name = '"'.addcslashes($name, "\0..\37\177'\"\\").'"';
        }
        else
        {
            $name = $this->_prep_q_encoding($name, true);
        }
    }

    $this->set_header('From', $name.' <'.$from.'>');
    $this->set_header('Return-Path', '<'.$from.'>');

    return $this;
}