Jump to content

sendmail script issues


rigbyae

Recommended Posts

Okay, pretty new to PHP here. I can read PHP, and understand most of it, just still running into some "stupid" issues. any help would be appreciated.

 

I've included the code for the script that I"m using, or trying to use...  Obviously, I've removed some key factors such as my exact email address and thankyou & error page locations.  The script will send an email to me, but the html code will be in the email body, and it won't send the message portion from the form.

 

I've double and triple checked the variable names to the html code for the form itself, and the variables are the same.

 

Any suggestions to what's going wrong?

----------my code----------------

<?php

 

/* Subject and Email Variables */

 

$emailSubject = 'Website Enquiry';

$webMaster = 'myemail';

 

/* Gathering Data Variables */

 

$nameField = $_POST['name'];

$emailField = $_POST['email'];

$phoneField = $_POST['phone'];

$formField = $_POST['form'];

 

$body = <<<EOD

<br /><hr><br />

Email: $emailField <br />

Name: $nameField <br />

Phone Number: $phoneField <br />

Message: $formField<br />

EOD;

 

 

$headers .= "Content-type: text/html\n\n";

if (mail($webMaster, $emailField, $emailSubject, $body, $headers)) {header("Location: http://www.mythankyoupage...etc");}

else {header("Location:http://www.myerrorpage...etc");}

 

?>

Link to comment
Share on other sites

Okay, pretty new to PHP here. I can read PHP, and understand most of it, just still running into some "stupid" issues. any help would be appreciated.

 

I've included the code for the script that I"m using, or trying to use...  Obviously, I've removed some key factors such as my exact email address and thankyou & error page locations.  The script will send an email to me, but the html code will be in the email body, and it won't send the message portion from the form.

 

I've double and triple checked the variable names to the html code for the form itself, and the variables are the same.

 

Any suggestions to what's going wrong?

----------my code----------------

<?php

 

/* Subject and Email Variables */

 

$emailSubject = 'Website Enquiry';

$webMaster = 'myemail';

 

/* Gathering Data Variables */

 

$nameField = $_POST['name'];

$emailField = $_POST['email'];

$phoneField = $_POST['phone'];

$formField = $_POST['form'];

 

$body = <<<EOD

<br /><hr><br />

Email: $emailField <br />

Name: $nameField <br />

Phone Number: $phoneField <br />

Message: $formField<br />

EOD;

 

 

$headers .= "Content-type: text/html\n\n";

if (mail($webMaster, $emailField, $emailSubject, $body, $headers)) {header("Location: http://www.mythankyoupage...etc");}

else {header("Location:http://www.myerrorpage...etc");}

 

?>

 

Recheck the function definition of mail().

 

mail  (  string $to  ,  string $subject  ,  string $message , string $headers );

 

Change: mail($webMaster, $emailField, $emailSubject, $body, $headers);

 

To: mail($emailField, $emailSubject, $body, $headers);

 

You can specify the sent from address in $headers.

 

Example:

 

$header = "From: $webMaster\n\n";

$headers .= "Content-type: text/html\n\n";

 

Hope that helps!

 

Link to comment
Share on other sites

Made the suggested changes, still getting the same issues.

 

The email sent to my account via the form looks as this:

 

<br /><hr><br />

Email: me@whatever.com <br />

Name: myname <br />

Phone Number: 0000101111 <br />

Message: <br />

 

The redirect to either the Thankyou.html or the Error.html works fine.

 

Looking for help in at the very least getting the message into the email sent, if at all possible getting the html code out of the sent email as well.

 

Thanks.

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.