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 = "me@xxxxxx.com"; //
$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
Share on other sites

Almost works.

Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay for dror.wolmer@gmail.com 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
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.