WordPress at a glance
function is not described


PHPMailer::addCustomHeader() public WP 1.0

Add a custom header. $name value can be overloaded to contain both header name and value (name:value).

{} It's a method of the class: PHPMailer{}

No Hooks.


null. Nothing.


$PHPMailer = new PHPMailer();
$PHPMailer->addCustomHeader( $name, $value );
$name(string) (required)
Custom header name
Header value

Code of PHPMailer::addCustomHeader() WP 5.7.2

public function addCustomHeader($name, $value = null)
    if (null === $value && strpos($name, ':') !== false) {
        //Value passed in as name:value
        list($name, $value) = explode(':', $name, 2);
    $name = trim($name);
    $value = trim($value);
    //Ensure name is not empty, and that neither name nor value contain line breaks
    if (empty($name) || strpbrk($name . $value, "\r\n") !== false) {
        if ($this->exceptions) {
            throw new Exception('Invalid header name or value');

        return false;
    $this->CustomHeader[] = [$name, $value];

    return true;