Sending Email Forms In Html Without Seeing Outlook
We are exploring different functions for mailing forms. (None of us are HTML'ers rather VB.net'ers.) The code I found and understood is as follows
Solution 1:
Here i have pasted a complete code for sending mail without opening any outlook or using gmail credentials etc. It uses PHP for sending mail. hope this helps you.
if(isset($_POST['submit'])) {
if(trim($_POST['contactname']) == '') {
$hasError = true;
} else {
$name = trim($_POST['contactname']);
}
if(trim($_POST['subject']) == '') {
$hasError = true;
} else {
$subject = trim($_POST['subject']);
}
if(trim($_POST['ContactNum']) == '' && is_numeric($_POST['ContactNum'])) {
$hasError = true;
} else {
$Contacting = trim($_POST['ContactNum']);
}
//Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) == '' && preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$_POST['email'])) {
$hasError = true;
} else {
$email = trim($_POST['email']);
}
if(trim($_POST['message']) == '') {
$hasError = true;
} else {
if(function_exists('stripslashes')) {
$comments = stripslashes(trim($_POST['message']));
} else {
$comments = trim($_POST['message']);
}
}
//----------------------Email Validation-----------------//functionEmVal($e)
{
return preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$e);
}
//If there is no error, send the emailif(!isset($hasError)) {
$emailTo = 'abc@abc.com';
$body = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments \n\nContact Number:\n $Contacting";
$headers = 'From: WebBestow <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
mail($emailTo, $subject, $body, $headers);
$emailSent = true;}
}
?>
You can udpate fields as per your requirments. And set action="youpage.php". this code should be in html document of yourpage.php
Post a Comment for "Sending Email Forms In Html Without Seeing Outlook"