I am trying to send a filled up form to a particular email address. But I have no Idea about it. I know a little PHP coding and as far I have studied online I found that PHP already have a mail() function. but that also have some problems. although most of that I did not understood properly.
here is the things I want to do:
I am requesting everyone to give me a details information about how I can do so.
thanks in advance..
Use PHPMailer to send mails in PHP
http://phpmailer.worxware.com/
PHPMailer wiki page:
https://code.google.com/a/apache-extras.org/p/phpmailer/wiki/UsefulTutorial
Use can use Gmail, Live or any other SMTP server to send mails Code:
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.example.com"; // SMTP server
$mail->From = "from@example.com";
$mail->AddAddress("myfriend@example.net");
$mail->Subject = "First PHPMailer Message";
$mail->Body = "Hi!
This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>
You can simply use php mail function with all the parameters for example mail ( $to ,$subject , $message, $headers ); Where $to, $subject, $message are php variables to contains their respective values. as you are posting data from the form so you can make $message from form. like $message = $_POST['FORM_FIELD_NAME'];
and $headers you set according to your requirement. For example
$headers = 'MIME-Version: 1.0' . " "; $headers .= 'Content-type: text/html; charset=iso-8859-1' . " "; $headers .= 'From: My Name <myemail@address.com>' . " ";
it can help you..
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.example.com"; // SMTP server
$mail->From = "from@example.com";
$mail->AddAddress("id@example.net");
$mail->Subject = "First PHPMailer Message";
$mail->Body = "Hi!
This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>