打开应用程序并在 python 中发送带有超链接的邮件(访问我的网站)
open application and send a mail with hyperlink (to visit my site) in python
如何在电子邮件中插入超链接作为消息以访问我的网站?
我的应用程序是由Python2.7用自己的框架制作的我正在使用休闲方法发送邮件。
def process_email(self,email_id,reson):
Emp_ID = email_id
message = reason
message += '<a href="localhost:8080">click me to visit</a>'
self.sendmail(to_user=Emp_ID,subject="Testinghyperlink",message=message)
但是我收到的电子邮件中有原始 html 代码:<a href="localhost:8080">click me to visit</a>
而不是点击我访问。提前致谢。
没有测试,但应该可以
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
Emp_ID = email_id
html_message='<a href="localhost:8080">click me to visit</a>'
self.sendmail(to_user=Emp_ID
html_content = MIMEText(html_message, 'html')
message = html_content
self.sendmail(to_user=Emp_ID,subject="Testinghyperlink",message=message)
通过对双引号使用转义序列 /"
> I changed this line of code. html_message='<a
> href=\"localhost:8080\">click me to visit</a>'
如何在电子邮件中插入超链接作为消息以访问我的网站?
我的应用程序是由Python2.7用自己的框架制作的我正在使用休闲方法发送邮件。
def process_email(self,email_id,reson):
Emp_ID = email_id
message = reason
message += '<a href="localhost:8080">click me to visit</a>'
self.sendmail(to_user=Emp_ID,subject="Testinghyperlink",message=message)
但是我收到的电子邮件中有原始 html 代码:<a href="localhost:8080">click me to visit</a>
而不是点击我访问。提前致谢。
没有测试,但应该可以
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
Emp_ID = email_id
html_message='<a href="localhost:8080">click me to visit</a>'
self.sendmail(to_user=Emp_ID
html_content = MIMEText(html_message, 'html')
message = html_content
self.sendmail(to_user=Emp_ID,subject="Testinghyperlink",message=message)
通过对双引号使用转义序列 /"
> I changed this line of code. html_message='<a
> href=\"localhost:8080\">click me to visit</a>'