Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecipientsQueue is not included in getToAddresses #2565

Open
frankforte opened this issue Nov 24, 2021 · 0 comments
Open

RecipientsQueue is not included in getToAddresses #2565

frankforte opened this issue Nov 24, 2021 · 0 comments

Comments

@frankforte
Copy link

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;
	}
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant