• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Multiple Email recipients with check boxes

New Here ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard

Copied

I have a list of recipients with email links. Can a check box be used to select specific names and have those addresses populate in the To: field on a blank email?

Views

587

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 13, 2019 Jan 13, 2019

onniec77729686  wrote

But sadly, I don't know how to get there. 😞

You would need to use some server-side language to process the information, which IF you ARE dealing with form information you should be doing anyway.

It's really quite easy. The below example is in it's simplest form. You loop through ALL the ticked checkboxes and send the email message to their designated email addresses, collected from the forms input/checkbox fields.

<?php

if(isset($_POST['submit'])) {

foreach ($_POST['email'] as $

...

Votes

Translate

Translate
Community Expert ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard

Copied

Yes, but it will need some coding. So that we can answer the question more specifically, what are you aiming to do? When you say 'To: field on a blank email', what exactly do you mean?

Wappler, the only real Dreamweaver alternative.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 13, 2019 Jan 13, 2019

Copy link to clipboard

Copied

When an email link is selected that recipient's address automatically shows in the email "To:" field. I have a roster of members where I would like someone to be able to select more than one name, have all the names show in the "To:" field, compose the email message and then send to all addresses at once. Like a group email. But sadly, I don't know how to get there. 😞

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 13, 2019 Jan 13, 2019

Copy link to clipboard

Copied

onniec77729686  wrote

But sadly, I don't know how to get there. 😞

You would need to use some server-side language to process the information, which IF you ARE dealing with form information you should be doing anyway.

It's really quite easy. The below example is in it's simplest form. You loop through ALL the ticked checkboxes and send the email message to their designated email addresses, collected from the forms input/checkbox fields.

<?php

if(isset($_POST['submit'])) {

foreach ($_POST['email'] as $email) {

mail($email, 'Subject','Message Goes Here', "From: Whoever");

}

}

?>

<h1>Send Email</h1>

<form name="send_email" action="index.php" method="post">

<p><input type="checkbox" name="email[]" value="email@address_1.com">email@address_1.com</p>

<p><input type="checkbox" name="email[]" value="email@address_2.com">email@address_2.com</p>

<input type="submit" name="submit" value="Submit" />

</form>

Breaking the above down (you should set the form 'action' field to the page which processes the script. I very often tend to keep the php script in the same file as the form itself, right at the top of the file, before anything else:

If you keep the script in the same page as the form you don't want the script to run when the page loads so you surround the script in a php 'if' query, testing to see if the form submit button has been clicked. If it has the script runs.

if(isset($_POST['submit'])) {

}

You then use a 'foreach' loop to loop through all the form checkboxes that have been checked:

foreach ($_POST['email'] as $email) {

}

Then mail your message to the specific emails using the php mail function:

mail($email, 'Subject','Message Goes Here', "From: Whoever");

You collect the email form field values into an array when the checkbox/s have been checked so the script can loop through them. That is why you have set the name field to 'email[]' - the brackets designates to store in an array of information:

<p><input type="checkbox" name="email[]" value="email@address_1.com">email@address_1.com</p>

That might help, a bit, maybe.

There are other more complicated workflows like using ajax to smooth the process of page reload but at this stage I think this will be enough for you to try and get your head around.

It looks more complex than it really is and it goes without saying you should always use validation on your forms. This is just a bare-bones example of the process without the all singing all dancing necessities in place. You can choose as many or as little of those as you like.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 13, 2019 Jan 13, 2019

Copy link to clipboard

Copied

Thanks for your help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2019 Jan 13, 2019

Copy link to clipboard

Copied

I have unmarked my answer as the correct one. This is so that other users will get the best answer possible. At this stage, it looks like osgood_​'s reply covers all of the necessary steps to take.

Wappler, the only real Dreamweaver alternative.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2019 Jan 13, 2019

Copy link to clipboard

Copied

onniec77729686  wrote

I have a list of recipients with email links. Can a check box be used to select specific names and have those addresses populate in the To: field on a blank email?

This sounds like a job for a dedicated e-mail client like MS Outlook rather than Dreamweaver.  Compose a message.  Use your address book of intended recipients.

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2019 Jun 07, 2019

Copy link to clipboard

Copied

LATEST

This makes no sense to me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines