mendoz Posted December 18, 2006 Share Posted December 18, 2006 Hey phpeole,Can any one direct me to a nice form to mail script or tutorial?I want a "contact us" form in my site that sends the data to my email.Something really basic,name,email,phone,text.Thanks,Dror Link to comment https://forums.phpfreaks.com/topic/31109-form-to-mail-anyone/ Share on other sites More sharing options...
AV1611 Posted December 18, 2006 Share Posted December 18, 2006 Look at the Contact Us on this site. If you like it, I will give you all the script.[url=http://baptistrevival.com]http://baptistrevival.com[/url] Link to comment https://forums.phpfreaks.com/topic/31109-form-to-mail-anyone/#findComment-143644 Share on other sites More sharing options...
mendoz Posted December 18, 2006 Author Share Posted December 18, 2006 That would be great, thanks! Link to comment https://forums.phpfreaks.com/topic/31109-form-to-mail-anyone/#findComment-143647 Share on other sites More sharing options...
AV1611 Posted December 18, 2006 Share Posted December 18, 2006 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"> <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 More sharing options...
mendoz Posted December 18, 2006 Author Share Posted December 18, 2006 Thanks a lot ! Link to comment https://forums.phpfreaks.com/topic/31109-form-to-mail-anyone/#findComment-143724 Share on other sites More sharing options...
mendoz Posted December 18, 2006 Author Share Posted December 18, 2006 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 24I 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 More sharing options...
AV1611 Posted December 18, 2006 Share Posted December 18, 2006 the $to has to be a valid account with relay priv Link to comment https://forums.phpfreaks.com/topic/31109-form-to-mail-anyone/#findComment-143774 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.