电子邮件发送给PHP后执行脚本
您好,我正在使用SMTP发送电子邮件。电子邮件正在完全发送Schusses,但是电子邮件发送脚本后的脚本不起作用。谁能帮我吗?
电子邮件正在成功发送,但作为回报,脚本没有执行。
还需要发送约2秒钟的电子邮件,但这并不重要,邮件问题是脚本
在此处无法使用的代码
<?php
require 'include/dbconfig.php';
require_once "vendor/autoload.php";
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
//PHPMailer Object
$mail = new PHPMailer(); //Argument true in constructor enables exceptions
// SMTP configuration
$mail->SMTPDebug = 1;
$mail->isSMTP();
$mail->Mailer = "smtp";
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "emailpassword";
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->isHTML(true);
$mail->setFrom('[email protected]', 'Sabir');
$mail->addAddress("[email protected]");
$mail->Subject = "Test";
$mail->Body = "Test Email";
$email_sent=$mail->send();
if(!$email_sent) { ?>
<script language="javascript" type="text/javascript">
alert('Something went wrong');
</script><?php
} else { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message');
</script>
<?php
}
?>
Hello I am sending email with smtp. Email is sending schusses fully but the script after email send script is not working. can anyone help me with this ?
Emails are sending successfully but in return the script is not executing.
Also email take like 2 seconds to send but it does not matter the mail issue is script is not working
Here's code
<?php
require 'include/dbconfig.php';
require_once "vendor/autoload.php";
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
//PHPMailer Object
$mail = new PHPMailer(); //Argument true in constructor enables exceptions
// SMTP configuration
$mail->SMTPDebug = 1;
$mail->isSMTP();
$mail->Mailer = "smtp";
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "emailpassword";
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->isHTML(true);
$mail->setFrom('[email protected]', 'Sabir');
$mail->addAddress("[email protected]");
$mail->Subject = "Test";
$mail->Body = "Test Email";
$email_sent=$mail->send();
if(!$email_sent) { ?>
<script language="javascript" type="text/javascript">
alert('Something went wrong');
</script><?php
} else { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message');
</script>
<?php
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
早上好,
您可以减少陈述:
看起来和工作应该这样:
您也不需要进行所有这些休息,
只需将JS放在回声中,然后删除它:
而是去做:
因此,它看起来就是这样:
编辑
几乎忘记了!
现在我们已经清除了一些代码,
但这不会那样工作。
您将需要与以下方式调整表格:
或进行Ajax调用:
Good morning,
you can cut your statements a bit down:
It should look and work like that:
Also you don´t need to make all this breaks,
just put your js in a echo and remove that:
instead go for:
So it would look like that:
Edit
Nearly forgot!
Now we have cleared the code a bit,
but it won´t work like that.
You will need to adjust your form aswell with:
Or go for an ajax call: