TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mayank Bhushan
NA
40
3.3k
the server responded with a status 405
Jun 14 2018 7:40 AM
My code is below--
$(
'#btnsubmit'
).click(
function
() {
$(
"#lblerrorName"
).css(
"display"
,
"none"
);
$(
"#lblerrorEmail"
).css(
"display"
,
"none"
);
$(
"#lblerrorSubject"
).css(
"display"
,
"none"
);
$(
"#lblerrorMessage"
).css(
"display"
,
"none"
);
$(
"#lbltextError"
).css(
"display"
,
"none"
);
Name = $(
"input[name=name]"
).val();
Email = $(
"input[name=email]"
).val();
Subject = $(
"input[name=subject]"
).val();
Message = $(
"textarea#message"
).val();
debugger
;
if
(Name ==
""
) {
$(
"#lblerrorName"
).css(
"display"
,
"block"
);
return
false
;
}
if
(Email ==
""
) {
$(
"#lblerrorEmail"
).css(
"display"
,
"block"
);
return
false
;
}
if
(Subject ==
""
) {
$(
"#lblerrorSubject"
).css(
"display"
,
"block"
);
return
false
;
}
if
(Message ==
""
) {
$(
"#lblerrorMessage"
).css(
"display"
,
"block"
);
return
false
;
}
Result =
"Name:"
+ Name +
" "
+
"<br/>Email:"
+ Email +
"<br/>Subject:"
+ Subject +
"<br/>Message:"
+ Message;
alert($(
"#name"
).val() +
"- "
+ $(
'#email'
).val() +
" -"
+ $(
"#subject"
).val() +
" -"
+ Message);
try
{
$.ajax({
url:
"contactmail.php"
,
type:
"post"
,
cache:
false
,
data: {
name: $(
"#name"
).val(),
email: $(
"#email"
).val(),
subject: $(
"#subject"
).val(),
dvResult: Message,
},
success:
function
(data) {
console.log(data);
$(
"#name"
).val(
''
);
$(
"#email"
).val(
''
);
$(
"#subject"
).val(
''
);
$(
"textarea#message"
).val(
''
);
}
});
}
catch
(e) {
alert(e);
}
});
</script>
Php code is
<?php
echo
'jfhdsfhsdfhsdjfhsdjfhsfhsfhsdh'
//include class.phpmailer.php class
require
'phpmailer/class.phpmailer.php'
;
//creates object
require
'PHPMailer-master/src/Exception.php'
;
require
'PHPMailer-master/src/PHPMailer.php'
;
require
'PHPMailer-master/src/SMTP.php'
;
//$mail = new PHPMailer(true);
//Load Composer's autoloader
// require 'vendor/autoload.php';
//$mail = new PHPMailer(true);
$name
=
strip_tags
(
$_POST
[
'name'
]);
$email
=
strip_tags
(
$_POST
[
'email'
]);
$subject
=
strip_tags
(
$_POST
[
'subject'
]);
$requiremrnt
=
strip_tags
(
$_POST
[
'dvResult'
]);
// echo ($full_name);
// echo ($email);
// echo ($phone);
// echo ($requiremrnt);
// $subject = "Orange Enquiry";
$headers
=
'MIME-Version: 1.0'
.
"\r\n"
;
$headers
.=
'Content-type: text/html; charset=iso-8859-1'
.
"\r\n"
;
// HTML email starts here
$message
=
"<html><body>"
;
$message
.=
"<div>Name: "
.
$name
.
"</div><br/>"
;
$message
.=
"<div> Email: "
.
$email
.
"</div><br/>"
;
$message
.=
"<div>Subject: "
.
$subject
.
"</div><br/>"
;
$message
.=
"<div> Requirement: "
.
$requiremrnt
.
"</div><br/>"
;
$message
.=
"</body></html>"
;
//$message = file_get_contents("mail.html");
// HTML email ends here
//Print_r($message);
//$message = str_replace("[xxResultTablexx]",$text_message,$message);
// try
// {
// $mail->IsSMTP();
// $mail->isHTML(true);
// $mail->SMTPDebug = 2;
// $mail->SMTPAuth = true;
// $mail->SMTPSecure = "tls";
// $mail->Host = "smtp.gmail.com";
// $mail->Port = 587;
// $mail->AddAddress('
[email protected]
');
// $mail->Username ="
[email protected]
";
// $mail->Password ="code@1234";
// $mail->SetFrom('
[email protected]
','Codeoid Quotation');
// $mail->AddReplyTo("
[email protected]
","Codeoid Quotation");
// $mail-> AddCC("
[email protected]
","Codeoid Quotation");
// $mail->Subject = $subject;
// $mail->Body = $message;
// $mail->AltBody = $message;
// echo($mail);
// if($mail->Send())
// {
// $msg = "<div class='alert alert-success'>
// Hi,<br /> ".$full_name." mail was successfully sent to ".$email." go and check, cheers :)
// </div>";
// }
// }
// catch(phpmailerException $ex)
// {
// $msg = "<div class='alert alert-warning'>".$ex->errorMessage()."</div>";
// echo($msg);
// }
$mail
=
new
PHPMailer(true);
// Passing `true` enables exceptions
require
'../phpmailer/PHPMailerAutoload.php'
;
try {
//Server settings
$mail
->SMTPDebug = 0;
// Enable verbose debug output
$mail
->isSMTP();
// Set mailer to use SMTP
$mail
->Host =
'smtp.gmail.com'
;
// Specify main and backup SMTP servers
$mail
->SMTPAuth = true;
// Enable SMTP authentication
$mail
->Username =
'
[email protected]
'
;
// SMTP username
$mail
->Password =
'code@1111'
;
// SMTP password
$mail
->SMTPSecure =
'tls'
;
// Enable TLS encryption, `ssl` also accepted
$mail
->Port = 587;
// TCP port to connect to
//Recipients
$mail
->setFrom(
'
[email protected]
'
,
'Orange Enquiry '
);
$mail
->addAddress(
'
[email protected]
'
,
'Orange Enquiry'
);
// Add a recipient
// Name is optional
$mail
->addReplyTo(
'
[email protected]
'
,
'Orange Enquiry'
);
$mail
->addCC(
'
[email protected]
'
);
$mail
->addBCC(
'
[email protected]
'
);
//Attachments
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
//Content
$mail
->isHTML(true);
// Set email format to HTML
$mail
->Subject =
$subject
;
$mail
->Body =
$message
;
$mail
->AltBody =
$message
;
$mail
->send();
echo
'Message has been sent'
;
} catch (Exception
$e
) {
echo
'Message could not be sent. Mailer Error: '
,
$mail
->ErrorInfo;
}
?>
Reply
Answers (
1
)
Play Local Video File On HTML5 Player
Post method not working