In this post discussed about how to send a email on form post value using php code. Normally the values posted in the form can be send through the particular email address. Based on this concept the feedback form and comments and queries can be posted.
PHP
Just store the values posted in the form in a variable and send the variable directly to the user given mailid $to = $_POST['username']; its support the SMTP $headers = "From: $from\r\n"; we cannot send a mail on the local server, if you want to send a email on local server just download and install the SMTP configuration on your local server
<?php
if(isset($_POST['submit'])!="")
{
$comments=$_POST['comments'];
$to = $_POST['email'];
$from = "mostlikers@gmail.com";
$subject = "Mostlikers mails";
$message= "Hello .$to. <br/>
Watch my full site <a href='http:\\www.karthickinfotech.blogspot.in'>Mostlikers</a>
.$comments";
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
mail($to, $subject, $message, $headers);
$email_error="<span style=color:red; font-size:16px;><b>Check your mail Now</b></span>";
}
?>
if(isset($_POST['submit'])!="")
{
$comments=$_POST['comments'];
$to = $_POST['email'];
$from = "mostlikers@gmail.com";
$subject = "Mostlikers mails";
$message= "Hello .$to. <br/>
Watch my full site <a href='http:\\www.karthickinfotech.blogspot.in'>Mostlikers</a>
.$comments";
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
mail($to, $subject, $message, $headers);
$email_error="<span style=color:red; font-size:16px;><b>Check your mail Now</b></span>";
}
?>
Post value send on mail echo the alert message on $email_error form. content $headers .= "Content-type: text/html\r\n"; mail format send mail($to, $subject, $message, $headers);
HTML
If you want to send a email to a particular mailid , use action="mailto:sample@sp.com". now this mail can be send to a particular user this method as follow an post commend form users.
<form class="form-wrapper" method="post">
<h1>Send Mail concept in PHP</h1>
<p><strong>Enter your Email ID </strong>
<input type="email" name="email" placeholder="Enter your Email" required="required" ></p>
<p><strong>Enter your password </strong>
<input type="text" name="comments" placeholder="Enter your commends" required="required" ></p>
<p align="center"><input type="submit" value="Send mail" name="submit" class="submit" id="submit"></p>
<p align="center"><?php if(isset($_POST['submit'])!="")
{
echo $email_error;
}
?></p>
</form>
<h1>Send Mail concept in PHP</h1>
<p><strong>Enter your Email ID </strong>
<input type="email" name="email" placeholder="Enter your Email" required="required" ></p>
<p><strong>Enter your password </strong>
<input type="text" name="comments" placeholder="Enter your commends" required="required" ></p>
<p align="center"><input type="submit" value="Send mail" name="submit" class="submit" id="submit"></p>
<p align="center"><?php if(isset($_POST['submit'])!="")
{
echo $email_error;
}
?></p>
</form>
No comments:
Post a Comment