Javascript 如何发送自定义邮件如果Razorpay付款成功,我已经尝试过,但它会在页面重新加载时发送邮件,
问题是在页面重新加载时调用了函数myemailfunction()auto,但我希望如果支付成功,那么应该调用它Javascript 如何发送自定义邮件如果Razorpay付款成功,我已经尝试过,但它会在页面重新加载时发送邮件,,javascript,php,payment-gateway,razorpay,Javascript,Php,Payment Gateway,Razorpay,问题是在页面重新加载时调用了函数myemailfunction()auto,但我希望如果支付成功,那么应该调用它 <?php $email = $_GET["your-email"] ; $headers = 'From: noreply@company.com'; // Set the subject of your email. $subject = "This is Test
<?php
$email = $_GET["your-email"] ;
$headers = 'From: noreply@company.com'; // Set the subject of your email.
$subject = "This is Test Mail";
$message = "This is Email Subject test url wwww.quantainfotech.com/shop";
?>
<script>
var options = {
"key": "abc", // Enter the Key ID generated from the Dashboard
"amount": 99*100,
"currency": "INR",
"name": "abc",
"description": "xyz",
"image": "img/url",
"handler": function (response){
"<?php myemailfunction($email,$subject,$message,$headers) ?>";
alert("Payment Successfull !! ");
window.location.href = '<?php echo $passurl; ?>';
die();
}
</script>
<?php
function myemailfunction(){
mail($email,$subject,$message,$headers);
}
?>
变量选项={
“键”:“abc”,//输入从仪表板生成的键ID
“金额”:99*100,
“货币”:“印度卢比”,
“名称”:“abc”,
“说明”:“xyz”,
“图像”:“img/url”,
“处理程序”:函数(响应){
"";
警报(“付款成功!!”;
window.location.href='';
模具();
}
这是否回答了您的问题?不,这不是我问题的答案。我的问题是为什么要使用myemailfunction()函数在页面重新加载时调用。这个重复的问题回答了为什么会发生这种情况。当页面加载时,PHP会运行,而不管JavaScript可能在做什么。每次页面加载时,它都会运行
,这将发送电子邮件。为了让脚本按您想要的方式工作,您需要处理程序对另一个页面执行ajax调用er PHP页面,用于处理电子邮件发送。