Trying To Send Email from variable

DS928
DS928 used Ask the Experts™
on
I have a form that I want to send an email to the email address that is put in the email field.  However what I did is not working.

http://www.bricooper.com

Click on "Share"

This is what I put.
// User settings
$to = "$email";
$subject = "Bri Cooper";

Open in new window

contact.php
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Did you get any error message on the screen? You can try like this in the variable,
$to = $email;

Open in new window

I tested your form and it is being submitted and it says, "Your message was successfully sent. " .. .just your inbox/spam folders whether you've got any email.
I just checked my inbox, it has come... so please change the email id here,

$to = "user@yourdomain.com";  /// your email ID to receive... not $email  

$email -> refers who is submitting the form...

So, it should be

$to = YOUR EMAIL ID;

Open in new window

CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Author

Commented:
OK, I need to set the form up so that where it says "Friends Email" this where the email goes to.  I am not getting any errors.  It has to work to where whatever email is in the Friends Email field, thats where the email will be sent to.
Yes, you're correct, then it works... what is the question now?

Author

Commented:
It doesnt work when i try it.  Put your email in the field on the form and see if you receive it
first time, it was worked.. now it is not...did you change anything?

Author

Commented:
$to = $email;

Is this correct?
Fixer of Problems
Most Valuable Expert 2014
Commented:
If you are trying to create a form to send email to others whose email is entered in the form by the user, you are creating a very inviting spam generator.  A malicious spammer can write a simple program that can use your form to send email to thousands of people until your ISP or web host shuts down your account.  Putting a form like that on your site is simply a bad idea.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial