Jump to content

Sending E-mails


Col2eight

Recommended Posts

Well, I already know how.

 

Here is my setup:

$EmailFrom = "MY EMAIL";

 

$EmailTo = THIS IS WHERE I WANT TO INPUT EMAILS!;

 

$Subject = "MY SUBJECT";

 

$Email = Trim(stripslashes($_POST['Email']));

 

 

 

// validation

 

$validationOK=true;

 

if (!$validationOK) {

 

print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";

 

exit;

 

}

 

 

 

// prepare email body text

 

$Body = "";

 

$Body .= "THIS IS MY BODY TEXT";

 

$Body .= "\n";

 

$Body .= "\n";

 

$Body .= "ANOTHER PART OF MY BODY";

 

 

 

// send email

 

$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

 

 

Alright, well that's my basic setup. I just want to know how to send the email to ANY email address I want with the textbox right above the submit button (on the index.php page). I know it's hard to understand and see without actually seeing it yourself, but help me out.

 

 

I have tried $Email and &_POST['Email'] and other things but still nothing. THANKS!

 

<3

Link to comment
Share on other sites

You use the $_POST super-global.

 

eg.

 

$_POST['Email'];

 

Also, just a few tips relating to your code. echo is generally better to use over print because it's faster.

 

Another small thing is it's a better idea to use the Location option for header() over a meta refresh.

 

eg.

 

header('Location: error.html');
exit;

Link to comment
Share on other sites

Sorry if I confused you :P

 

Assmusing that the name property of the input element that you want to enter the email address into is "Email" (Case matters), just make $EmailTo = $_POST['Email'];

Haha it's fine. :P But yeah, I already tried that. It just takes me to my error page and the email (obviously) is never sent.

 

wait, hold on. I messed up! thanks haha. I just realized that I changed "Email" to "mail" before starting on this. :\ I'm an idiot.

 

Thanks again!

Link to comment
Share on other sites

Am I missing something? Because you posted this:

 

$validationOK=true;

if (!$validationOK) {

print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";

exit;

}

 

(!$validationOK) would never validate to true.. Because all you do is set $validationOK to true then do nothing else regarding that variable.

 

I also just realized your $Email variable is already set to $_POST['Email']. Maybe it would be best if you post your form.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.