Jump to content

Recommended Posts

I have been working on a webform which is new to me. When testing it I discovered the host company required 2 email addresses (normal one and root) in order to validate. So I had to add the code they suggested to the sendmail.php file as seen below.

 

Will this validate and if not what would be the correct code in order for these problems to be corrected? Thanks.

 

 

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php 
mail("service@site.com", "Register Interest Form Results", $_REQUEST[message], "From: $_REQUEST[email]", "-froot@site.com".$_REQUEST[email]); 

$MESSAGE_BODY = "Name: ".$_POST["name"]." "; 
$MESSAGE_BODY .= "Email: ".$_POST["email"]." "; 
$MESSAGE_BODY .= "Phone: ".$_POST["phone"]." ";
$MESSAGE_BODY .= "Company: ".$_POST["company"]." ";
$MESSAGE_BODY .= "Jobtitle: ".$_POST["jobtitle"]." ";
$MESSAGE_BODY .= "Besttime2call: ".$_POST["besttime2call"]." ";
$MESSAGE_BODY .= "Howdidyouhear: ".$_POST["howdidyouhear"]." ";
$boxes = '';
if (isset($_POST['boxes']) && is_array($_POST['boxes']))
  $boxes = implode(', ', $_POST['boxes']);

$MESSAGE_BODY .= "Options: ".$boxes;


$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])." "; 
mail($ToEmail, $EmailSubject, $MESSAGE_BODY) or die ("Failure");

header( "Location: http://www.site.com/thankyou.html" ); 
?>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/154178-realistic-form-code/
Share on other sites

Doubtful, not sure why they would require the root@site.com

 

Have you tried it like this...

 

mail("service@site.com", "Register Interest Form Results", $_REQUEST['message'], "From: $_REQUEST['email']", "-f".$_REQUEST['email']); 

 

I generally add the -f which simply sets the "from" at the sendmail level. Which generally yields good results. If your host requires it then yes. You need it. If it does not, then no. You can omit it.

Link to comment
https://forums.phpfreaks.com/topic/154178-realistic-form-code/#findComment-810703
Share on other sites

It doesn't seem to have displayed  :'(

The hosts said you have to use the -f parameter. What do you use for that if its sent from a html page?

 

 

I have never seen a setup like that so only your host would know the correct configuration, which I assume they supplied to you and you added to the above?

 

Yes the (mail); and the (header); part at the end of the code is what they asked me to use.

 

 

Link to comment
https://forums.phpfreaks.com/topic/154178-realistic-form-code/#findComment-811565
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.