【问题标题】:Is it possible to hack mailto?可以破解mailto吗?
【发布时间】:2013-07-08 11:34:00
【问题描述】:

很抱歉这个挑衅的话题,但我想不出比“hack”更好的词来形容我想做的事!

在我的网站上,我提供到其他网站的链接,并根据用户的要求,在框架或弹出窗口中显示该网站的页面。这些显示的页面通常有一个 mailto-tag。

我发现单击 mailto 链接会启动我不再使用但将其作为已安装程序保留在我机器上的 Outlook 非常烦人。

我想做的是:

1) 选择 mailto 标签的主题和电子邮件地址部分。 2) 弹出一个 HTML 表单,其中预先填写了电子邮件地址和主题。 3) 通过我网站的邮件服务器而不是通过 Outlook 或任何其他邮件客户端发送电子邮件。

有没有办法做到这一点?

提前感谢您 - 再次为具有挑衅性的主题行道歉!

干杯!

乌塔姆

【问题讨论】:

  • 用户可以告诉 Gmail 处理这些链接。

标签: html-email email mailto


【解决方案1】:

使用 javascript 尝试一下。

使用像 jQuery 这样的框架很容易,因此可以在框架或弹出窗口中找到这样的标签。 您可以通过以下方式尝试:

var allATags = $('myFrameId').find('a');
$(allATags).each(function(index, element){
    var href = $(element).attr('href');
    //here you shall try to find out if there a mailto Link or a normal link, e.g. using regular expression or indexOf()
    [...]
    if (isMailToLink){
        //split the href String at the signs '&' with which the subject, mail, etc is splitted and removing the mailto, putting all in own variables
        [...]
        $(element).attr('href', 'javascript:void(0);');
        $(element).click(function(){
           showMyMailForm(toMail, mailSubject, mailBody);
        });
    }
});

在框架或弹出窗口中打开文档时,等待文档被加载,然后运行您的代码以使用您的 mailform-mailer 替换该文档上所有现有的 mailto-links。

代码只是一种试图激发灵感的方式,没有工作代码。

【讨论】:

  • 谢谢 - 我认为这对我有很大帮助。
【解决方案2】:

用户可以设置他们的默认电子邮件客户端,这里有几个链接可能会有所帮助:

当然这是由用户控制的,所以它会帮助你个人,而不是强迫别人使用特定的程序。

您可以轻松地将 url 参数传递到您的联系人登录页面/电子邮件表单而不是 mailto 链接,可以使用 href="http://landingpage.com/index.php?email=you@you.com&subject=hello" 之类的东西来预先填写通用联系人/电子邮件表单字段。

【讨论】:

    猜你喜欢
    • 2011-08-11
    • 1970-01-01
    • 2013-06-30
    • 2021-07-04
    • 2022-01-26
    • 1970-01-01
    • 2013-10-01
    • 2019-11-16
    • 1970-01-01
    相关资源
    最近更新 更多