PHP SMTP email example with SMS option
<?php
// http://phpmailer.worxware.com/?pg=examplebsmtp
$name = $_POST['name'] ;
$phone = $_POST['phone'] ;
$message = $name . '<br>' . $phone . '<br>' . $_POST['message'] ;
require 'PHPMailerAutoload.php';
//PHPMailer Object
$mail = new PHPMailer;
// Instantiate Class
$mail = new PHPMailer();
// Set up SMTP
$mail->IsSMTP(); // Sets up a SMTP connection
$mail->SMTPDebug = 2; // This will print debugging info
$mail->SMTPAuth = true; // Connection with the SMTP does require authorization
$mail->SMTPSecure = "tls"; // Connect using a TLS connection
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Encoding = '7bit'; // SMS uses 7-bit encoding
// set email format to HTML
$mail->IsHTML(true);
// Authentication
$mail->Username = "juan@popcreativegroup.com"; // Login
$mail->Password = "popjuan7480#"; // Password
// Compose
$mail->AddReplyTo("alex@popcreativegroup.com","7866835225");
// $mail->setFrom('popadmin@popcreativegroup.com', 'POP Admin');
$mail->setFrom('popadmin@popcreativegroup.com', $name ) ;
$mail->Subject = "New Mobile Message"; // Subject (which isn't required)
$mail->Body = $message; // Body of our message
// Send To alex
$mail->AddAddress( "7866835225@txt.att.net" ); // Where to send it
//$mail->AddAddress( "juan@popcreativegroup.com" ); // Where to send it
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "<br><br>Thank you for contacting us. We will be in touch with you very soon.";
<div class="container">
<div class="row">
<form action="email.php" method="post" >
<div class="col-lg-6">
<div class="form-group">
<label for="InputName">Your Name</label>
<div class="input-group">
<input type="text" class="form-control" name="name" id="name" placeholder="Enter Name" >
<span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span></div>
</div>
<div class="form-group">
<label for="InputEmail">Your Phone Number</label>
<div class="input-group">
<input type="phone" class="form-control" id="phone" name="phone" placeholder="305-123-1337" >
<span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span></div>
</div>
<div class="form-group">
<label for="InputMessage">Message</label>
<div class="input-group"
>
<textarea name="message" id="message" class="form-control" rows="5" ></textarea>
<span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span></div>
</div>
<input type="submit" name="submit" value="Submit" class="btn btn-info pull-right">
</div>
</form>
<hr class="featurette-divider hidden-lg">
</div>
</div>