-1

I created form and want into to send mail to my mail when a user submit a request. I found a php script which suites my form and its working fine with other form, but when I try to use that script for my form its not working as expected. This is my form in html-

 <form action="contact.php" method="post" name="form1">
                            <div class="form-group">
                                <input type="text" class="form-control" id="Name" placeholder="Name*" name="name">
                            </div>
                            <div class="form-group">
                                <input type="phone" class="form-control" id="Phone" placeholder="Phone*" name="phone">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control" id="Address" placeholder="Full Address*" name="address">
                            </div>
                            <div class="form-group">
                                <textarea class="form-control" rows="3" placeholder="Order - List Outlets and Meals*" name="order"></textarea>
                            </div>
                            <div class="form-group">
                                <label><input style="vertical-align: center;"type="checkbox" /> Accept  the <a class="" data-toggle="modal" data-target="#myModal">Terms & Conditions</a>
                                </label>
                            </div>
                            <a href="contact.php" class="btn-block">ORDER!</a>
                        </form>

and this is my php script- here

darla_sud
  • 359
  • 1
  • 4
  • 15

1 Answers1

1

make sure the php script is in the same directory as the form

<form action="contact.php" method="post" name="form1">
  <!--content-->
  <input type="submit" value="ok" />
</form>

to send mail using phpmailer https://github.com/PHPMailer/PHPMailer,

require_once('class.phpmailer.php');

require_once("PHPMailerAutoload.php");

$mail->IsSMTP(); // telling the class to use SMTP

$mail->SMTPAuth   = true;                  // enable SMTP authentication

$mail->SMTPSecure = "tls";                 // sets the prefix to the servier

$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server

$mail->Port       = 587;                   // set the SMTP port for the 

$mail->Username   = "yourusername@gmail.com";  // GMAIL username

$mail->Password   = "yourpassword";            // GMAIL password

$mail->SetFrom('name@yourdomain.com', 'First Last');

$mail->AddReplyTo("name@yourdomain.com","First Last");

$mail->Subject    = "PHPMailer Test Subject via smtp (Gmail), basic";

$mail->AltBody    = "To view the message, please use an HTML compatible";

$mail->MsgHTML($body);

$address = "whoto@otherdomain.com";
$mail->AddAddress($address, "John Doe");

if(!$mail->Send()) {

  echo "Mailer Error: " . $mail->ErrorInfo;

} else {

  echo "Message sent!";

}
Alvaromero
  • 11
  • 1