#2565·PHPMailer

RecipientsQueue is not included in getToAddresses

Author: frankforteCreated Nov 24, 2021Updated Nov 24, 2021

There should be a way to get all recipients before calling send(). For example, if we call:

$recipients = $phpmailer->getToAddresses();

This list might be empty if the addresses were added to $phpmailer->RecipientsQueue instead of $phpmailer->to

All of the get*Addresses methods should include the RecipientsQueue, or we should have a second method to return all recipients, including those that are in the queue. Maybe something like this:

public function getAllToAddresses(){
    return $this->getOrDequeueAddresses('to');
}
public function getAllCcAddresses(){
    return $this->getOrDequeueAddresses('cc');
}
public function getAllBccAddresses(){
    return $this->getOrDequeueAddresses('bcc');
}

protected getOrDequeueAddresses($kind){
       return array_merge( $this->{$kind}, array_filter(
	$this->RecipientsQueue,
	static function ($params) use ($kind) {
		return $params[0] == $kind;
	}
));
}