-1

I am trying to create a web page that will have a list of individuals, and after each individual's name I will create an "Email" button which will direct the user to a PHP form that allows the user to fill in their name, email address, and a comment field for other miscellaneous information, and then click a "Submit" button to email the individual.

I want to create one PHP form that will update depending upon which individual's name (the individual from the list) is selected and will show the individual's name, but not their email address. This question is close (specifically the Edit #1 section), but I want to both (a) send the email to a specific individual on the list, and (b) not show the email address to either the user or bots that will inevitably be scanning the page. This web page is essentially what my client wants to do.

I did find one question on here (which I inadvertently closed before copying the URL) which mentioned using a config file, but I'm not sure how to do that, or if it's a good solution.

Community
  • 1
  • 1
SWorden
  • 1
  • 4
  • 2
    Thats called BCC (Blind Carbon Copy) or sending the emails seperate from eachother – Jordy Mar 04 '15 at 20:10
  • 2
    As the e-mail is sent by the server, the e-mail address never needs to be on a web-page, just the user's name or ID so that you can get the e-mail address from the database at the back-end. – jeroen Mar 04 '15 at 20:12
  • 1
    Put the people in a database table -- their names, e-mail addresses, etc. Identify them with a unique value (number, guid, etc. [the table's primary key]). Display their information on the website from the database, but in the e-mail form, only supply their unique ID. Use that to look up the real e-mail from the database before you sent the e-mail. – Cᴏʀʏ Mar 04 '15 at 20:12
  • Thanks for the replies. For some reason I didn't get any notification. This project is active again and this will help a lot. – SWorden Jun 01 '15 at 18:14

2 Answers2

0

You'd want to create a third variable. A "recipient_id" or something. that way, you show the options like so

<select name="recipient">
    <?php foreach ($recipients as $recipient){ ?>
    <option value="<?php echo $recipient['id'] ?>"><?php echo $recipient['name'] ?></option>
    <?php } ?>
</select>

And then look up the email based on the recipient ID on the backend. You never send the email to the client that way.

-1
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

Should do the trick. You can then hardcode $to in your script and use 'case' to compare receipient name versus email address or store it in the DB so you can also create an 'admin' script to add/remove receipients from the list without knowing PHP and access to the server.

  • I downvoted this answer because there's no indication from the OP that they need help sending mail, only that they want to keep the addresses hidden. Secondly, you said "hardcode" the to address -- there are many individuals, do you suggest having a giant `if` block with a hard-coded e-mail for each individual? That's a poor solution. – Cᴏʀʏ Mar 04 '15 at 21:01
  • 'depending on number of individuals' is what I forgot to add. And this is why I've mentioned hardcoded or DB. And the question is how to send an email without showing the email address. One could use form with action 'mailto:' to send an email (not with PHP however). – Grzesiek My Mar 04 '15 at 21:12