如何使用 href url 传递变量?
How to pass a variable with href url?
下面是我在 python.
中使用 Flask 发送电子邮件的代码
def sendPasswordResetLink(email, token):
message = Message()
message.subject = "Reset your password"
message.sender = "********@gmail.com"
message.recipients = email.split()
message.html = '<p>Hello there,</p>\n' \
'<p>Please click on the below link to reset your password</p>\n' \
'<a href=http://localhost:5002/resetpassword.html?token= +token+>'
mail.send(message)
<a href....
行有问题。它没有在我收到的邮件中打印任何内容。我正在使用烧瓶邮件扩展。有人可以给我快速解决这个问题吗?
正如我所说,我使用的是 flask-mail 扩展,它提供了一个简单的界面来使用我们的 Flask 应用程序设置 SMTP 并从我们的视图和脚本发送消息。
预期行为 - 它应该向我的 gmail 发送一封主题为 "Reset your password" 的邮件,并且在邮件正文中我应该得到
你好呀,
请点击下方link重置密码。
http://localhost:5002/resetpassword.html?token=2
token 是我随函数定义一起发送的参数。它包含请求重置密码的用户的用户标识。
但是 URL 没有打印在我收到的邮件中。
def sendPasswordResetLink(email, token):
message = Message()
message.subject = "Reset your password"
message.sender = "********@gmail.com"
message.recipients = email.split()
message.html = '<p>Hello there,</p>\n' \
'<p>Please click on the below link to reset your password</p>\n' \
'<a href="http://localhost:5002/resetpassword.html?token=' + token + '">Some message here</a>'
mail.send(message)
您的问题是您没有转义 '...'
字符串,因此永远不会将 token
添加到组合中。但是您也没有以 </a>
结束 <a>
标记。因为没有消息。这是一些 examples.
下面是我在 python.
中使用 Flask 发送电子邮件的代码def sendPasswordResetLink(email, token):
message = Message()
message.subject = "Reset your password"
message.sender = "********@gmail.com"
message.recipients = email.split()
message.html = '<p>Hello there,</p>\n' \
'<p>Please click on the below link to reset your password</p>\n' \
'<a href=http://localhost:5002/resetpassword.html?token= +token+>'
mail.send(message)
<a href....
行有问题。它没有在我收到的邮件中打印任何内容。我正在使用烧瓶邮件扩展。有人可以给我快速解决这个问题吗?
正如我所说,我使用的是 flask-mail 扩展,它提供了一个简单的界面来使用我们的 Flask 应用程序设置 SMTP 并从我们的视图和脚本发送消息。
预期行为 - 它应该向我的 gmail 发送一封主题为 "Reset your password" 的邮件,并且在邮件正文中我应该得到 你好呀, 请点击下方link重置密码。 http://localhost:5002/resetpassword.html?token=2
token 是我随函数定义一起发送的参数。它包含请求重置密码的用户的用户标识。 但是 URL 没有打印在我收到的邮件中。
def sendPasswordResetLink(email, token):
message = Message()
message.subject = "Reset your password"
message.sender = "********@gmail.com"
message.recipients = email.split()
message.html = '<p>Hello there,</p>\n' \
'<p>Please click on the below link to reset your password</p>\n' \
'<a href="http://localhost:5002/resetpassword.html?token=' + token + '">Some message here</a>'
mail.send(message)
您的问题是您没有转义 '...'
字符串,因此永远不会将 token
添加到组合中。但是您也没有以 </a>
结束 <a>
标记。因为没有消息。这是一些 examples.