Simon R
02-19-2010, 08:22 AM
Hello All!
Im new here and to php! Im having a few problems with a email form, i can get this to send
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
But not this -
<?php
mail('sales@vandiscount.co.uk','Test mail','The mail function is working!');
echo 'Mail sent!';
?>
This one gives me the error -
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in \\nas01\nas\v\a\vandiscount.co.uk\web\mailtest.php on line 2
Mail sent!
Then if i try this in my code it send but i receive nothing -
<?php
if(isset($_POST['submit'])) {
$to = "sales@vandiscount.co.uk";
$subject = "Form Submission";
$name_field = $_POST['firstname1'];
$email_field = $_POST['companyname1'];
$number_field = $_POST['lastname1'];
$time_field = $_POST['mobile1'];
$comments_field = $_POST['phone1'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
} else {
echo "message sent!";
}
?>
and heres what im actaully using as the mailform page, sorry for the large amount but its driving me insane! -
<tr>
<td bgcolor="#C0C0C0" width="148"><b>
<font face="Arial">Contact us below</font></b><p align="center"><b>
<font face="Arial" size="2">(Use the TAB Key to move down the form)</font></b></td>
</tr>
<tr>
<td width="148" height="55">
<b><font face="Arial" size="2">Your name</font></b><font face="Arial"><input style="width: 143; background-color: #ffffa0; height:24" title="Your Google Toolbar can fill this in for you. Select AutoFill" type="text" value="" name="firstname1" size="20"></font></td></tr>
<tr>
<td height="50" width="148">
<b><font face="Arial" size="2">Your number</font></b><font face="Arial"><input style="width: 143; background-color: #ffffa0; height:25" title="Your Google Toolbar can fill this in for you. Select AutoFill" type="text" value="" name="lastname1" size="20"></font></td></tr>
<tr>
<td width="148" height="50">
<b><font face="Arial" size="2">Your email</font></b><font face="Arial"><input style="width: 143;height:25" type="text" value="" name="companyname1" size="20"></font></td></tr>
<tr>
<td width="148">
<b><font face="Arial" size="2">Your requirements</font></b><font face="Arial"><input style="width: 143; background-color: #ffffa0; height:132" title="Your Google Toolbar can fill this in for you. Select AutoFill" type="text" value="" name="phone1" size="20"></font></td></tr>
<tr>
<td width="148" height="52"><b><font face="Arial" size="2">Preferred time to
contact you</font></b><font face="Arial"><input style="width: 143; background-color: #ffffa0; height:22" type="text" value="" name="mobile1" size="20"></font></td></tr>
<tr>
<td align="center" width="148"><font face="Arial, Arial, Helvetica">
<input class="sendbutton" type="submit" value=" Submit Form " name="submit_apply1"> </font></td></tr></tbody></table>
Im new here and to php! Im having a few problems with a email form, i can get this to send
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
But not this -
<?php
mail('sales@vandiscount.co.uk','Test mail','The mail function is working!');
echo 'Mail sent!';
?>
This one gives me the error -
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in \\nas01\nas\v\a\vandiscount.co.uk\web\mailtest.php on line 2
Mail sent!
Then if i try this in my code it send but i receive nothing -
<?php
if(isset($_POST['submit'])) {
$to = "sales@vandiscount.co.uk";
$subject = "Form Submission";
$name_field = $_POST['firstname1'];
$email_field = $_POST['companyname1'];
$number_field = $_POST['lastname1'];
$time_field = $_POST['mobile1'];
$comments_field = $_POST['phone1'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
} else {
echo "message sent!";
}
?>
and heres what im actaully using as the mailform page, sorry for the large amount but its driving me insane! -
<tr>
<td bgcolor="#C0C0C0" width="148"><b>
<font face="Arial">Contact us below</font></b><p align="center"><b>
<font face="Arial" size="2">(Use the TAB Key to move down the form)</font></b></td>
</tr>
<tr>
<td width="148" height="55">
<b><font face="Arial" size="2">Your name</font></b><font face="Arial"><input style="width: 143; background-color: #ffffa0; height:24" title="Your Google Toolbar can fill this in for you. Select AutoFill" type="text" value="" name="firstname1" size="20"></font></td></tr>
<tr>
<td height="50" width="148">
<b><font face="Arial" size="2">Your number</font></b><font face="Arial"><input style="width: 143; background-color: #ffffa0; height:25" title="Your Google Toolbar can fill this in for you. Select AutoFill" type="text" value="" name="lastname1" size="20"></font></td></tr>
<tr>
<td width="148" height="50">
<b><font face="Arial" size="2">Your email</font></b><font face="Arial"><input style="width: 143;height:25" type="text" value="" name="companyname1" size="20"></font></td></tr>
<tr>
<td width="148">
<b><font face="Arial" size="2">Your requirements</font></b><font face="Arial"><input style="width: 143; background-color: #ffffa0; height:132" title="Your Google Toolbar can fill this in for you. Select AutoFill" type="text" value="" name="phone1" size="20"></font></td></tr>
<tr>
<td width="148" height="52"><b><font face="Arial" size="2">Preferred time to
contact you</font></b><font face="Arial"><input style="width: 143; background-color: #ffffa0; height:22" type="text" value="" name="mobile1" size="20"></font></td></tr>
<tr>
<td align="center" width="148"><font face="Arial, Arial, Helvetica">
<input class="sendbutton" type="submit" value=" Submit Form " name="submit_apply1"> </font></td></tr></tbody></table>