Jump to content

Form to mail anyone?


mendoz

Recommended Posts

Here is a simple mail form:
[code]
<h3>Contact Us</h3>

<form method="post" action="send.php">
<table>
<tr>
<td><p>Name:</p></td>
<td><p>Email:</p></td>
</tr>

<tr>
<td><p><input name="name" type="text" size="30" class="box"></p></td>
<td><p><input name="email" type="text" size="30" class="box"></p></td>
</tr>
<tr>
<td colspan="2"><p>Subject:</p></td>
</tr>
<tr>
<td colspan="2"><p><input name="subject" type="text" size="66" class="box"></p></td>
</tr>
<tr>
<td colspan="2"><p>Message:</p></td>
</tr>
<tr>
<td colspan="2"><p><textarea name="msg" cols="50" rows="4"></textarea></p></td>
</tr>
</table>

<input type="reset" value="Reset">&nbsp;<input type="submit" value="Send">
</form>
[/code]
and here is the mail script send.php
[code]
<?php
$to = "[email protected]"; //
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$msg = $_POST['msg'];
$sub = "Online Email Form";
$messub = "Subject: ".$subject."\r\n" ;
$mesmsg .= "Message: ".$msg."\r\n" ;
$mesname .= "Name: ".$name."\r\n" ;
$mesemail .= "Email: ".$email."\r\n" ;
$body=$messub.$mesname.$mesemail.$mesmsg;

$headers = 'From: '. $name . "\r\n" .
  'Reply-To: '. $email . "\r\n" .
  'X-Mailer: PHP/' . phpversion();

if(empty($name) || empty($email) || empty($subject) || empty($msg)) {
echo " <h3>You must fill in all the information.</h3>";
}
elseif(!ereg("^[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(.[a-zA-Z0-9-]+)*(.[a-zA-Z]{2,3})$",$email)){
print " <h3>You entered an invalid email address</h3>";
} else {
mail($to, $sub, $body, $headers);
print " <h3><center>Thanks, ".$name.", for contacting us...</center></h3>";
}
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/31109-form-to-mail-anyone/#findComment-143717
Share on other sites

Almost works.

Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay for [email protected] in D:\hshome\control-\control-pc.co.il\test\test2.php on line 24


I have mail relay turned on, according to my host, outgoing SMTP server the whole deal.

Do I need to configure anything?

Thanks,
Dror
Link to comment
https://forums.phpfreaks.com/topic/31109-form-to-mail-anyone/#findComment-143739
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.