-
I notice that the address that is used for i.e. Fervent foodies is also used for The Conversation. I tried to clear it as you see below on Fervent foodies but php didn't like that lol! foreach($_POST['growgroups'] as $growgroups)
{
if ($growgroups === 'Fervent Foodies')
{
$mail->Subject = "Interested in Grow Group Fervent Foodies";
$mail->addAddress("sitemaster@1usda.org");
$mail->send();
$mail->addAddress("");
}
if ($growgroups === 'The Conversation')
{
$mail->Subject = "Interested in Grow Group The Conversation";
$mail->addAddress('michel.bkyc@gmail.com');
$mail->send();
}
if ($growgroups === 'Wednesday Night Bible Study')
{
$mail->Subject = "Interested in Grow Group Wedensay Night Bible Study";
$mail->addAddress('michel.bkyc@gmail.com');
$mail->send();
}
if ($growgroups === 'Its Not About Me')
{
$mail->Subject = "Interested in Grow Group It's Not About Me";
$mail->addAddress('michel.bkyc@gmail.com');
$mail->send();
}
if ($growgroups === 'Young Couples Mentorship')
{
$mail->Subject = "Interested in Grow Group Young Couples Mentorship";
$mail->addAddress('sitemaster@1usda.org');
$mail->send();
}
if ($growgroups === 'Whats Next')
{
$mail->Subject = "Interested in Grow Group Whats New";
$mail->addAddress("michel.bkyc@gmail.com");
$mail->send();
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
There's a clue in the name of the method |
Beta Was this translation helpful? Give feedback.
-
I want to use this code on laptopswish but can you explain what changes are required it to start working? |
Beta Was this translation helpful? Give feedback.
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 calladdAddress
repeatedly (even if you callsend
between them), it will send to all of those people. You can clear the list of addresses the message goes to by callingclearAddresses()
. In your code, call$mail->clearAddresses()
after each call to$mail->send()
and it should work as you want.