I have tried the following and I am unable to send the email still. My hosting provider permits phpmail as I get email from my other Joomla websites easily on this hosting.
Now here goes the public.html file:
<html>
<head></head>
<body>
<script type="text/javascript">
function submitForm(){
var formName=document.forms["contact-us"];
var name=formName.elements["name"].value;
var email=formName.elements["email"].value;
var msg=formName.elements["msg"].value;
var phone = formName.elements["phone"].value;
if(name=='' || email=='' || msg=='' || phone=='')
alert("Please Input all fields");
else
{
var dataString = 'name1='+ name + '&email1='+ email + '&msg1='+ msg + '&phone1='+ phone;
$.ajax({
type:"POST",
url:"index.php",
data:dataString,
cache:false,
success: function(){
alert("Email Sent Successfully!");
}
});
}
return false;
}
function Validate()
{
var stop=false;
var x=document.forms["contact-us"]["email"].value;
var p=document.forms["contact-us"]["phone"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if(isNaN(p)){
alert("Please enter your correct phone number without '+' or '-'");
stop=true;
}else{
var temp = Number(p);
if(temp == 0){
alert("Please provide a valid number.");
stop=true;
}
}
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address!");
stop=true;
}
if(stop){
return false;
}
else
return submitForm();
}
</script>
</body>
</html>
and then I have some code in index.php file to deal with it. Here it goes:
<?php
if ($dataString)
{
$recipient = $_GET['sagar@sagaryadav.com'];
$sender = $_GET'[Avighna Website'];
$body = $_GET["$dataString"];
$headers = 'From: info@avighnamerchandising.com' . "
" .
'Reply-To: info@avighnamerchandising.com' . "
" .
'X-Mailer: PHP/' . phpversion(5.5.31);
$sendMail = mail($recipient, $sender, $body, $headers);
}
?>
Now, what's wrong. Why am I not able to send this email from the form and what is it that needs to be there in the index.php file that would make it work?