Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

PHP website contact form? Not sending mail

the mail() function

Moderators: macek, egami, gesf

PHP website contact form? Not sending mail

Postby onlinegamesnz » Mon Mar 19, 2012 3:36 pm

Hi, im quite new to php and dont know much. I have just setup my server with IMAP, POP and SMTP servers and i know my SMTP server can send mail. Im using hMailServer

My contact forum code is

<code>
<?php

/************************
* Variables you can change
*************************/

$mailto = "myemailgoeshere"; // Enter your mail addres here.
$name = ucwords($_POST['name']);
$subject = "Message from $name"; // Enter the subject here.
$email = $_POST['email'];
$message = $_POST['message'];

if(strlen($_POST['name']) < 1 ){
echo 'email_error';
}

else if(strlen($email) < 1 ) {
echo 'email_error';
}

else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", $email)) {
echo 'email_error';
}

else if(strlen($message) < 1 ){
echo 'email_error';

} else {

// NOW SEND THE ENQUIRY

$email_message="\n\n" .
"Name: " .
ucwords($name) .
"\n" .
"Email: " .
$email .
"\n" .
"Comments: " .
"\n" .
$message .
"\n" .
"\n\n" ;

$email_message = trim(stripslashes($email_message));
mail($mailto, $subject, $email_message, "From: \"$vname\" <".$email.">\nReply-To: \"".ucwords($name)."\" <".$email.">\nX-Mailer: PHP/" . phpversion() );

}
?>
</code>

Where do i set the server?? Ie localhost or 127.0.0.1 so the script to send mail via my SMTP server running on localhost??

Thanks
onlinegamesnz
New php-forum User
New php-forum User
 
Posts: 10
Joined: Wed Nov 23, 2011 2:52 am

Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.