Mailto链接到Python-Telegram-Bot消息,用于让用户发送预编译电子邮件

发布于 2025-02-08 10:13:06 字数 640 浏览 2 评论 0原文

是否有一种简单的方法可以显示一个超链接,以让用户在Python-Telegram-bot中发送电子邮件?我已经尝试过,但是链接将用户重定向到电子邮件域的网页。我将重定向到默认邮件应用程序。

context.bot.sendMessage(chat_id=update.message.chat_id, text="Contact us <a href='mailto:[email protected][email protected]&subject=Support%20request%20&body=Write%20here%20your%20issue:'>here</a> to solve the problem together.", parse_mode="HTML")

感谢您的帮助 ;)

is there a simple way to show a hyperlink for letting user send an email in python-telegram-bot? I've tried this but the link redirects the user to a web page of the email domain. I would have a redirect into a default mail app.

context.bot.sendMessage(chat_id=update.message.chat_id, text="Contact us <a href='mailto:[email protected][email protected]&subject=Support%20request%20&body=Write%20here%20your%20issue:'>here</a> to solve the problem together.", parse_mode="HTML")

Thank you for your help ;)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执妄 2025-02-15 10:13:06

问题是电报无法识别mailto: url。为了将其包装到“可接受的” https url中,您可以使用Tinyurl等URL缩短服务。这样,https url将重定向到mailto url,这就是您想要的。

这是一个例子:

$ curl -I https://a-random-url-shortener.com/yhbv7ucf
HTTP/2 308 
...
location: mailto:[email protected],[email protected]?subject=Example%20Subject&body=Example%20Body
...

The problem is that Telegram doesn't recognize mailto: urls. In order to wrap it into an "acceptable" https url, you can use the URL shortening services like TinyUrl. This way, the https url will redirect into a mailto url which is what you want.

Here's an example:

$ curl -I https://a-random-url-shortener.com/yhbv7ucf
HTTP/2 308 
...
location: mailto:[email protected],[email protected]?subject=Example%20Subject&body=Example%20Body
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文