Skip to content

Sending to different emails #2887

Closed Answered by Synchro
JonthueM asked this question in Q&A
Mar 28, 2023 · 2 comments · 4 replies
Discussion options

You must be logged in to vote

There's a clue in the name of the method addAddress adds an address; it doesn't set the addresses the message is going to, and that list of recipients is retained for the life of the PHPMailer instance. So if you call addAddress repeatedly (even if you call send between them), it will send to all of those people. You can clear the list of addresses the message goes to by calling clearAddresses(). In your code, call $mail->clearAddresses() after each call to $mail->send() and it should work as you want.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@JonthueM
Comment options

@Synchro
Comment options

@JonthueM
Comment options

Answer selected by JonthueM
Comment options

You must be logged in to vote
1 reply
@Synchro
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants