python - 为什么我的来自 django 电子邮件的 html 链接不可点击?

标签 python html django email hyperlink

我通过 Django 发送了以下邮件

    subject, from_email, to = 'site Registration', 'support@site.com', self.second_email
    text_content = 'Click on link to finish registration'
    html_content = '<html><body><a href="site.com/accounts/user/' + self.slug +'">Click Here</a></body></html>'
    msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
    msg.attach_alternative(html_content, "text/html")
    msg.send()

当我访问电子邮件(google 和 yahoo 电子邮件)时,它们都以蓝色显示“单击此处”文本(我认为这意味着它被识别为链接),但是,该链接不可点击且不链接到站点.com/acc...我做错了什么?

谢谢!

最佳答案

您可能需要使其成为一个有效的 URL:(注意包含的方案)

<a href="http://site.com/accounts/user/' + self.slug +'">

关于python - 为什么我的来自 django 电子邮件的 html 链接不可点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6464737/

相关文章:

python - 伏特龙 : Device communication aborted: segmentationNotSupported

python - 使用 NLTK 进行西类牙语 POS 标记?

python - Y错误的scikit Mixtypes

javascript - 如何解决 Prototype 和 DatePicker 或 Tooltip 之间的 jQuery 冲突?

html - 具有最大宽度的容器在调整大小时不会包装内联 block 子级

python - 限制选择并验证 django 的外键到相关对象(也在 REST 中)

django - django 中的多步表单和模型继承

python Pandas TypeError : Cannot compare type 'Timestamp' with type 'float'

javascript - JS 元素 onclick 事件没有被触发

python - Django - 用于单个 Django 项目中多个应用程序的 admin.py