Ajax contact form not working - php

I am working on a website with an Ajax contact form. Tried a lot, it successfully sends a mail without headers below is my code please help me to fix this
code
<div class="form">
<div class="title">
<h2 class="orange"><span class="orange">Contact</span> US</h2>
</div>
<div class="height15"></div>
<div id="return_message"></div>
<div class="field">
<label>First Name:</label>
<input name="name" type="text" />
</div>
<div class="field">
<label>Phone Number:</label>
<input name="phone" type="text" />
</div>
<div class="field">
<label>Email Address:</label>
<input name="email" type="text" />
</div>
<label>Message:</label>
<textarea name="message" cols="" rows=""></textarea>
<div class="clear"></div>
<a class="org_btn more submit" id="submit" href="#.">Submit</a> </div>
<script language="javascript">
$(document).ready(function() {
$("#menu_btn").click(function(){
$("#sub_menu").slideToggle("slow");
});
//Contact us form validation
$('#return_message').hide();
$('#submit').click(function(event){
var name = $('#name').val();
var phone = $('#phone').val();
var email = $('#email').val();
var message = $('#message').val();
if( (name=='') || (phone=='') || (email=='') || (message=='') )
{
$('#name').addClass('error_active');
$('#phone').addClass('error_active');
$('#email').addClass('error_active');
$('#message').addClass('error_active');
}
else
{
var regex = /^([a-zA-Z0-9_\.\-\+])+\#(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if(!regex.test(email))
{
alert("Please Enter valid email address");
$('#email').addClass('error_active');
}
else
{
$.ajax(
{
type: 'POST',
data: ({name : name, phone : phone, email : email, message : message}),
url: 'send_mail.php',
success: function(data)
{
if(data)
{
$('#return_message').show('slow').html("<p>Email has been sent...</p>");
$('#name').val('');
$('#phone').val('');
$('#email').val('');
$('#message').val('');
$('#name').removeClass('error_active');
$('#phone').removeClass('error_active');
$('#email').removeClass('error_active');
$('#message').removeClass('error_active');
}
else
{
$('#return_message').show('slow').html("<p>Email has not been sent...</p>");
}
}
});
}
}
});
});
</script>
php code
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$to = "info#kodspider.com"; // Please put your email addres.
$subject = "Marthoman Vidyapeedom"; //Please put subject of your email.
if($phone!='')
{
$message2 = $message.'\r\nPhone:'.$phone;
}
else
{
$message2 = $message;
}
$message = $message.'\r\nPhone:'.$phone;
$headers = "From: ".$email;
$sent = mail( $to, $subject, $message2, $headers );
if($sent)
{
echo "success";
}
else
{
echo "error";
}
?>

you have given
<input name="name" type="text" />
but in jquery your calling
$('#name').val('')
in jquery # selector is used only for id
make change
<input name="name" id="name" type="text" />
for more details in jquery read this

Related

How I can add reCaptcha in this form?

I want to add Google reCaptcha in this form I tried all things but all in vain.. What I need to do to make form successfully submitted.. and also make reCaptcha a required field using Ajax form submission...
HTML:-
<form id="contact-form" class="uk-form">
<fieldset>
<label>Name <em>*</em></label>
<input type="text" name="name" class="textfield" id="name" value="" />
<label>E-mail <em>*</em></label>
<input type="email" name="email" class="textfield" id="email" value="" />
<label>Services <em>*</em></label>
<input type="text" name="subject" class="textfield" id="subject" value="" />
<label>Message <em>*</em></label>
<textarea name="message" id="message" class="textarea" cols="2" rows="6"></textarea>
<div class="clearfix">
<div class="g-recaptcha" data-sitekey="My_Site_Key"></div>
</div>
<label> </label>
<button type="submit" name="submit" class="uk-button uk-button-small idz-button-blue" id="buttonsend">Submit</button>
<span class="loading" style="display: none;">Please wait..</span>
</fieldset>
</form>
JS:-
$('#buttonsend').click( function() {
var name = $('#name').val();
var subject = $('#subject').val();
var email = $('#email').val();
var message = $('#message').val();
$('.loading').fadeIn('fast');
if (name != "" && subject != "" && email != "" && message != "")
{
$.ajax(
{
url: './contact-us.php',
type: 'POST',
data: "name=" + name + "&subject=" + subject + "&email=" + email + "&message=" + message,
success: function(result)
{
$('.loading').fadeOut('fast');
if(result == "email_error") {
$('#email').css({"background":"#FFFCFC","border":"1px solid #ffadad"}).next('.require').text(' !');
} else {
$('#name, #subject, #email, #message').val("","Name","Subject","Email","Message");
$('<div class="uk-alert uk-alert-success uk-text-center uk-margin-medium-bottom" data-uk-alert><p>Your message has been sent successfully. Thank you!</p></div>').insertBefore('#contact-form');
$('.uk-alert').fadeOut(5000, function(){ $(this).remove(); });
}
}
}
);
return false;
}
else
{
$('.loading').fadeOut('fast');
if( name == "","Name") $('#name').css({"background":"#FFFCFC","border":"1px solid #ffadad"});
if(subject == "","Subject") $('#subject').css({"background":"#FFFCFC","border":"1px solid #ffadad"});
if(email == "","Email" ) $('#email').css({"background":"#FFFCFC","border":"1px solid #ffadad"});
if(message == "","Message") $('#message').css({"background":"#FFFCFC","border":"1px solid #ffadad"});
return false;
}
});
$('#name, #subject, #email,#message').focus(function(){
$(this).css({"border":"none","background":"#fafafa","border":"1px solid #ccc"});
});
PHP:-
$to = "xyz#mydomain.com";
$subject = "Contact Inquiry";
$name = $_POST['name'];
$email = $_POST['email'];
$services = $_POST['subject'];
$message = $_POST['message'];
$str = "Name: ".$name."\r\n\r\n"."Services: ".$services."\r\n\r\n"."Message: ".$message."\r\n\r\n".
$headers = "From: $email";
$sent = mail($to, $subject, $str, $headers) ;

Html & Php Contact Form with Email Submission

Db Connection
$server = 'localhost:8080';
$username = 'root';
$password = '';
$database = 'resort';
$connect = mysqli_connect($server, $username, $password ) or die(mysqli_error.'error connecting to db');
//select database
mysqli_select_db ($database, $connect) or die(mysqli_error.'error selecting db');
if(!empty($_POST)){
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$filtered_email = filter_var($email, FILTER_VALIDATE_EMAIL);
if(!empty($name) && !empty($email) && !empty($message))
{
//insert the data into DB
mysql_query("INSERT into contactform (contact_id, contact_name, contact_email, contact_phone, message )
VALUES ('', '".$name."',
'".$email."', '".$phone."',
'".$message."' )") or die(mysqli_error());
//prepare email headers
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=isoo-8859-1\r\n";
$headers .= "From: ".$email."\r\n";
$to = 'mahesh.gulve004#gmail.com,'.$email;
$subject = 'Contact Form';
$body = 'From: <br/> Name: '.$name.' <br/>E-mail: '.$email.'<br/>Phone: '.$phone.'<br/>Message: '.$message;
//before sending the email make sure that the email address is correct
if ( $filtered_email == false ) {
echo json_encode(array(
'error' => true,
'msg' => "The email address entered it's not correct!"
));
exit;
}
$mail = mail($to, $subject, $body, $headers);
//finally send the email
if ( $mail ) {
//finally send the ajax response
echo json_encode(array(
'error' => false
));
exit;
} else {
//finally send the ajax response
echo json_encode(array(
'error' => true,
'msg' => "Opss...Something went wrong. Message was not sent!"
));
exit;
}
} else {
echo json_encode(array(
'error' => true,
'msg' => "You haven't completed all required fileds!"
));
exit;
}
}
$(function() {
//CONTACT FORM AJAX SUBMIT
$('#send').click(function() {
$.ajax({
url: 'mailer.php',
type: 'POST',
dataType: 'json',
data: $(this).serialize(),
success: function(data) {
console.log(data);
if (data.error === true) {
$('#error').css('display', 'block');
var error = document.getElementById('error');
error.innerHTML = data.msg;
setTimeout(function() {
window.scrollTo(0, 1);
}, 100);
} else {
$('#note').show();
$('#error').hide();
$("#fields").hide();
}
}
});
return false;
});
});
<div class="col-md-6">
<div id="test-form" class="white-popup-block mfp-hide" style="width:400px;float:left;">
<div id="formcontent">
<div id="formheader" style="border-bottom:1px solid #e3e3e3;margin-bottom:20px;">
<h1 style="color:#37bc9b;font-size:33px;">We will get back to you...</h1>
</div>
<fieldset style="border:0;">
<div id="note">
<h2>Message sent successfully!</h2>
</div>
<div class="contact-form">
<form id="contactForm" method="post" action="">
<div class="form-group">
<label for="name">Name</label>
<span id="name-info" class="info">
<input type="text" placeholder="" id="name" name="name" class="form-control demoInputBox">
</div>
<div class="form-group">
<label for="email">Email</label>
<span id="email-info" class="info">
<input type="text" placeholder="" id="email" name="email" class="form-control demoInputBox">
</div>
<div class="form-group">
<label for="phone">Phone</label>
<span id="phone-info" class="info">
<input type="text" id="phone" name="phone" class="form-control demoInputBox">
</div>
<div class="form-group">
<label for="message">Message</label>
<span id="message-info" class="info">
<textarea placeholder="" rows="5" id="message" name="message" class="form-control demoInputBox">
</textarea>
</div>
<input class="btn btn-info" id="send" type="submit" value="Submit"/>
</form>
</div>
</fieldset>
</div>
</div>
</div>
<div id="error"></div>
Issue is that when I click on submit the data is not submitted in fact I will say nothing happens by clicking submit button. Errors does not occur so no way to find out what the problem is. I am trying to build a contact form that can send mail. So you will also get some code related to it.
To submit the form you should use:
$('#contactForm').submit(function(){
//your ajax function
return false;
});
try $("#contactForm").serialize() instead of $(this).serialize()

PHP email form without Refreshing Page

I am trying to set up my page so that when I a form is submitted it emails and a message is displayed without refreshing the page.
I have tried to do this using jQuery/Ajax however I cannot get any emails sent now
Without the Ajax/jQuery, the PHP works just fine but just doesnt include the refresh feature
Any help would be appreciated
PHP (submitForm.php):
<?php
$name = isset($_POST['name']);
$email = isset($_POST['email']);
$phone = isset($_POST['phone']);
$message = isset($_POST['message']);
$feedback = '';
if($name && $email && $phone && $message) {
$name = ($_POST['name']);
$email = ($_POST['email']);
$phone = ($_POST['phone']);
$message = ($_POST['message']);
}
$to = "arshdsoni#gmail.com";
$subject = 'Soni Repairs - Support Request';
$body = <<<EMAIL
Hi There!
My name is $name.
Message: $message.
My email is: $email
Phone Number: $phone
Kind Regards
EMAIL;
$header = "From: $email";
if($_POST) {
if($name == '' || $email == '' || $phone == '' || $message == '') {
$feedback = "Nothing received!";
}
else {
mail($to, $subject, $body, $header);
$feedback = '*Message Received! You will receive a reply shortly!';
}
}
?>
jQuery/Ajax:
function submitForm() {
var name=document.getElementById('name').value;
var dataString = 'name'+ name;
$.ajax({
type:"post",
url:"submitForm.php",
cache:false,
success: function(html) {
$('#feedback').html(html);
}
});
return false;
}
FORM:
<form id="contact" action="#">
<h3>Get in Touch:</h3>
<h4><span id="star" class="glyphicon glyphicon-asterisk"></span>We aim to reply within 24 hours!</h4>
<fieldset>
<input name="name" placeholder="Your Name" type="text" tabindex="1" required>
</fieldset>
<fieldset>
<input name="email" placeholder="Your Email Address" type="email" tabindex="2" required>
</fieldset>
<fieldset>
<input name="phone" placeholder="Your Phone Number" type="tel" tabindex="3" required>
</fieldset>
<fieldset>
<textarea id="textarea" name="message" placeholder="Describe your problem...." tabindex="5" required></textarea>
</fieldset>
<fieldset>
<button name="submit" type="submit" id="contact-submit submitBtn" data-submit="...Sending" "return submitForm();">Submit</button>
</fieldset>
</form>
Issues:
if you usedocument.getElementById you must use id on your elements
Add the data to your ajax request
HTML:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$( "#submitBtn" ).click(function( event ) {
alert('pressed');
//values
var name=document.getElementById('name').value;
var email=document.getElementById('email').value;
var phone=document.getElementById('phone').value;
var message=document.getElementById('message').value;
var dataString = {"name": name, "email":email, "phone": phone, "message":message}
$.ajax({
type:"post",
url:"submitForm.php",
data: dataString,
success: function(html) {
$('#feedback').html(html);
}
});
event.preventDefault();
});
});
</script>
</head>
<body>
<form id="contact" method="POST">
<h3>Get in Touch:</h3>
<h4><span id="star" class="glyphicon glyphicon-asterisk"></span>We aim to reply within 24 hours!</h4>
<fieldset>
<input id="name" placeholder="Your Name" type="text" tabindex="1" required>
</fieldset>
<fieldset>
<input id="email" placeholder="Your Email Address" type="email" tabindex="2" required>
</fieldset>
<fieldset>
<input id="phone" placeholder="Your Phone Number" type="tel" tabindex="3" required>
</fieldset>
<fieldset>
<textarea id="message" placeholder="Describe your problem...." tabindex="5" required></textarea>
</fieldset>
<fieldset>
<button name="submit" id="submitBtn">Submit</button>
</fieldset>
</form>
<div id="feedback"></div>
</body>
</html>
PHP
<?php
if(isset($_POST['name'], $_POST['email'], $_POST['phone'], $_POST['message'])){
//Post data
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
//mail settings
$to = "arshdsoni#gmail.com";
$subject = 'Soni Repairs - Support Request';
$body = <<<EMAIL
Hi There!
My name is $name.
Message: $message.
My email is: $email
Phone Number: $phone
Kind Regards
EMAIL;
if(mail($to, $subject, $body, $header)){
$feedback = '*Message sent! You will receive a reply shortly!';
}else{
$feedback = '*Message failed to send';
}
}else{
$feedback = 'Missing Params';
}
echo $feedback;
This is your ajax, where you went wrong
$.ajax({
type:"post",
url:"submitForm.php",
cache:false,
success: function(html) {
$('#feedback').html(html);
}
});
You forgot to include the data to be posted
$.ajax({
type:"post",
url:"submitForm.php",
cache:false,
data {
name: $('#name').val(),
email: $('#email').val(),
phone: $('#phone').val(),
message: $('#msg').val()
}
success: function(html) {
$('#feedback').html(html);
}
});
The keys name, email, message and phone should be as is; because you used $_POST['name'], $_POST['email'], $_POST['message'] and $_POST['phone'].
The calls$('#name').val(), $('#email').val(), $('#phone').val(), $('#message').val() have been made assuming that your input elements have ids name, email, message and phone respectively. JS uses ids rather than names.
Refer to jQuery Ajax documentation for more details.
I do not see you sending the data to PHP file anywhere in your AJAX code
NOTE: Use serialize() function if you want to send all the form data. Else send it separately like
var formDatas = {name:"name",email:"emailID"};
function submitForm() {
var name=document.getElementById('name').value;
var dataString = 'name'+ name;
var formDatas = $('#formID').serialize(); // Send form data
$.ajax({
type:"post",
url:"submitForm.php",
data : {datas : formDatas }
cache:false,
success: function(html) {
$('#feedback').html(html);
}
});
return false;
}
Your references
jQuery Serialize()
jQuery ajax()

PHP #mail textarea $message not being sent

So this must look as another PHP email question. However, after researching and trying all available replies on Stackoverflow, I can't seem to get the <textarea name="description"></textarea> to get the content and send it with the rest of the email $to, $from, $body and $headers:
Here's the HTML:
<form method="post" id="tarqus_form">
<div class="inner-frame inverse p-7">
<h5>Hola,</h5>
<div>
<h5>mi nombre es</h5>
<input type="text" class="name" name="name" placeholder="Nombre (obligatorio)" id="name">
</div>
<div>
<h5>y me gustaría saber</h5>
</div>
<div>
<h5>sobre:</h5>
<input type="text" class="subject" name="subject" placeholder="Asunto" id="asunto">
</div>
<div>
<h5>Me pueden responder</h5>
</div>
<div>
<h5>a este:</h5>
<input type="text" class="email" name="email" placeholder="Correo electrónico (obligatorio)" id="email">
</div>
<div>
<h5>Quisiera decir:</h5>
</div>
<div>
<!-- HERE's the textarea -->
<textarea name="description" rows="3" class="message" placeholder="Ingresa tu mensaje (obligatorio)" id="message"></textarea>
</div>
<div class="row pt-21">
<div class="col-md-6 p-0">
<h5>Antispam:</h5>
<div>
<h5>¿12-7+2?</h5>
</div>
<div>
<input type="text" class="antispam pl-0 mt-7 ml-0" name="antispam" placeholder="Respuesta (obligatorio)" id="antispam">
</div>
</div>
<div class="col-md-6 text-center">
<input type="submit" value="Enviar" class="submit uppercase">
</div>
</div>
</div>
</form>
I'm creating some validations with jQuery and if they pass, the POST method is called. This hasn't been a problem because the email is actually being sent with everything I need except the message on the textarea.
jQuery validations:
$("#tarqus_form").submit(function(e){
e.preventDefault();
var name = $("#name").val();
var subject = $("#asunto").val();
var email = $("#email").val();
var text = $("#message").val();
var antispam = $("#antispam").val();
var dataString = 'email=' + email + '&text=' + text + '&subject=' + subject + '&name=' + name;
// Custom RegExp for verifying email authenticity
function isValidEmail(emailAddress) {
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0- \uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))#((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
return pattern.test(emailAddress);
};
if (isValidEmail(email) && (name.length > 1) && (text.length > 1) && (antispam == 7)){
$.ajax({
type: "POST",
url: "/form.php",
data: dataString,
success: function(response){
console.log(response);
$('#tarqus_form').fadeOut(500);
$('.success').removeClass('hidden').fadeIn(500);
}
});
} else{
$('.error').removeClass('hidden').fadeIn(1000);
setTimeout(function(){
$('.error').addClass('hidden');
}, 5000);
}
return false;
});
When this passes, the form sends the email according to this PHP code:
<?php
$name = $_POST['name'];
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $_POST['description'];
$from = 'TARQUS | Arquitectura MX <contacto#tarqus.mx>';
$headers.="From:".$from."\n";
$to = 'contacto#tarqus.mx';
$body = "Nombre: $name\n Asunto: $subject\n E-Mail: $email\n Mensaje: $message\n";
// detect & prevent header injections
$test = "/(content-type|bcc:|cc:|to:)/i";
foreach ( $_POST as $key => $val ) {
if ( preg_match( $test, $val ) ) {
exit;
}
}
#mail($to, $subject, $body, $headers);
?>
As you can see, I'm using the $_POST method for my name="description" textarea. I've also tried with the $_REQUEST method.
Here's an example email, all of the changes that I've made to the PHP code sent the email except for the $message in the $body:
Nombre: Name Lastname
Asunto: Subject
E-Mail: example#mail.com
Mensaje: === empty === :(
you got error on your php file
when you getting post DATA in ajax you sending TEXT not DESCRIPTION
$name = $_POST['name'];
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $_POST['text'];
$from = 'TARQUS | Arquitectura MX <contacto#tarqus.mx>';
$headers.="From:".$from."\n";

I'm getting a 500 internal server error with my PHP contact form

I have a PHP contact form here:
leongaban.com
Below is a screenshot showing the 500 (Internal Server Error) I'm getting after I click Submit
HTML form
<div class="the-form">
<form id="contact">
<div id="status"></div>
<div>
<label for="name">Your Name</label>
<input type="text" name="name" id="name" value="" tabindex="1">
</div>
<div>
<label for="email">Your Email</label>
<input type="text" name="email" id="email" value="" tabindex="2">
</div>
<div>
<label for="textarea">Message:</label>
<textarea cols="40" rows="8" name="comments" id="comments" tabindex="3"></textarea>
</div>
<div>
<input class="submit-button" id="submit" type="submit" value="Submit" tabindex="5">
</div>
</form><!-- #contact -->
</div><!-- .the-form -->
My Javascript
$(function(){
$('#submit').click(function(){
var form_data = {
name: $('#name').val(),
email: $('#email').val(),
comments: $('#comments').val()
};
$.ajax({
url: "includes/send.php",
type: 'POST',
data: form_data,
success: function(status) {
if (status == 'success') {
$('#status').html('<h3 class="success">Thank You!</h3>')
.hide().fadeIn(2000);
} else {
$('#status').html('<p class="error">Both name and email are required fields.</p>')
.hide().fadeIn(2000);
}
} // end send contact form
}); //end ajax
return false;
}); //end send contact form click
});
My PHP
<?php
$name = $_POST['name'];
$email = trim($_POST['email']);
$comments = $_POST['comments'];
$error = array();
$site_owners_email = 'myEmail#gmail.com'; // Replace this with your own email address
$site_owners_name = 'Leon Gaban'; // replace with your name
if (strlen($name) < 2) {
$error['name'] = "Please enter your name.";
}
if (!preg_match('/^[a-z0-9&\'\.\-_\+]+#[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) {
$error['email'] = "Please enter a valid email address.";
}
if (!$error) {
$response = 'success';
$subject = $name . ' needs help from CodePopper!';
$body = 'Codepopper,' . "\n\nName: " . $name .
"\nEmail: " . $email .
"\nComments: " . $comments;
require_once 'lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('hostname', 25)
->setUsername('username')
->setPassword('password')
;
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance();
$message->setSubject($subject);
$message->setFrom(array('myEmail#gmail.com' => 'leongaban.com'));
$message->setTo(array('myEmail#gmail.com' => 'Leon Gaban'));
$message->setBody($body);
$result = $mailer->send($message);
echo $response;
} # end if no error
else {
$response = 'error';
echo $response;
} # end if there was an error sending
I forgot to enter in my email host settings into my send.php file
$transport = Swift_SmtpTransport::newInstance('leongaban.com', 25)
->setUsername('my email')
->setPassword('my password');
Side note, I now have root access to my server :)

Categories