php - 我正在通过 phpmailer 在 gmail 中发送消息,其中包含一个链接,该链接将在 localhost(xampp)中的我的 php 页面上重定向
问题描述
我正在通过 phpmailer 在 gmail 中发送消息,其中包含一个链接,该链接将在 localhost(xampp)中的我的 php 页面上重定向。但它无法在我的本地主机中的我的 php 页面上重定向。这是我的代码链接我的本地主机页面
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'MilkBank Account Verification';
$mail->Body = 'Click the link to verify your account.<br>
<a href="http:localhost//MilkBank2.0/UserPages/BackEnd/verify.be.update" >Register Account!! </a>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
可以重定向吗?
解决方案
只需添加 if-else 标签
if ($mail->Send())
{
header("Location:Yourfile.php");//echo "Message Sent!";
}
else
{
echo "Message could not be sent. ";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
推荐阅读
- symfony - 这是否可以使用 API 平台与 Heroku 获得 Mercure 协议?
- c# - 在 WPF C# 应用程序中,列表框绑定源目录包含“#”,但应用程序无法加载它
- mysql - 在 Laravel 中连接三个表时,求和查询加倍
- python - 为什么python输出与目标网站的html不匹配
- r - 如何修复“文件错误(文件,“rt”):无法打开连接
- java - spring data jpa:更新@many边表后,无法通过findAll @one边表以相同的方法获得正确的更改
- python - 如何链接多个组合框表中的两个组合框?
- python - 为什么BERT中的矩阵叫Query、Key和Value?
- sql-server - 具有 Entity Framework Core 的表分区
- database - 在数据库中存储多个企业的开放和关闭时间的最佳方法是什么