最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - HTML5 How to open the default email program without composing a new message - Stack Overflow

programmeradmin2浏览0评论

I know you can have someone open their local email application (like 'mail.app' on mac or outlook on windows) and pose a new message with the following

window.location.href = "mailto:[email protected]";

I was wondering if it is possible to open the local email application without also posing a new message?

The use-case is, after registration, people need to check their email to confirm their account. I do not need them to send a message.

UX notes outside the scope of this question I do not force a redirect, but rather I have a 'check my email' and 'skip' button after logging in. I have coded, that 'if the email contains gmail' to redirect to mail.google, but there is no way to exhaustively hard-code all possible email addresses and to which url they should be redirected? therefore if the email address is not any of the major ones, I would like to opt to open the user's local email client (without posing an email message) - if this is possible.

I know you can have someone open their local email application (like 'mail.app' on mac or outlook on windows) and pose a new message with the following

window.location.href = "mailto:[email protected]";

I was wondering if it is possible to open the local email application without also posing a new message?

The use-case is, after registration, people need to check their email to confirm their account. I do not need them to send a message.

UX notes outside the scope of this question I do not force a redirect, but rather I have a 'check my email' and 'skip' button after logging in. I have coded, that 'if the email contains gmail.' to redirect to mail.google., but there is no way to exhaustively hard-code all possible email addresses and to which url they should be redirected? therefore if the email address is not any of the major ones, I would like to opt to open the user's local email client (without posing an email message) - if this is possible.

Share Improve this question edited Jan 11, 2018 at 16:02 user1709076 asked Jan 11, 2018 at 15:07 user1709076user1709076 2,85610 gold badges42 silver badges62 bronze badges 7
  • 1 I don't think this is a good practice. You should let the user open their email themselve. Imagine, on PC, that your default email program is Outlook but you use Gmail. – Nicolas Commented Jan 11, 2018 at 15:10
  • 2 Not possible. Being able to run an arbitrary program on the user's machine would be a huge security issue. Also, the number of people who haven't set up their default client with their email address is (un)surprisingly high. – user5734311 Commented Jan 11, 2018 at 15:10
  • 1 Just tell the user to check their mail. Almost every site ever which has a registration process just has a simple reminder message like that. Thinks of the big sites - Amazon etc. If what you were suggesting was possible, they'd have done it by now. If the user forgets to check, that's their problem, not yours. Users can be daft, but this is taking patronising them to quite an extreme level. You don't even know that they necessarily access their mail on the same device as they're viewing your site. And this rarely works for web-based mail either, which is used by millions of people. – ADyson Commented Jan 11, 2018 at 15:16
  • 1 Also, who's to say the user wants to check their mail and confirm the account immediately? They might want to leave it till later when they have time, or whatever. Even if doing this action wasn't a security breach, it's certainly intrusive (and, as I already mentioned, probably quite insulting to the intelligence of most users, even the daft ones). P.S. The use case supported by browsers, where the user clicks on a link to pose a message, is pletely different, because the user is actively choosing to do that - it's not an indirect, unexpected consequence of a different action. – ADyson Commented Jan 11, 2018 at 15:19
  • 1 Hi I appreciate the UX responses. And yes, I do not force a redirect, but rather I have a 'check my email' and 'skip' button. I'd like the focus to be on whether this is possible or not. I have coded, that 'if the email contains gmail.' to redirect to mail.google., but there is no way to exhaustively hard-code all possible email addresses and to which url they should be redirected? therefore if the email address is not any of the major ones, I would like to opt to open the user's local email client. – user1709076 Commented Jan 11, 2018 at 15:59
 |  Show 2 more ments

1 Answer 1

Reset to default 7

This isn't possible from a technical perspective. There's no mechanism provided for it via JavaScript. The browser simply doesn't have that kind of permission to open a desktop app, and nor should it.

It may open a mail client specifically using the "mailto:" protocol for the single purpose of pasting the email address from the mailto link into the user's default mail client. Similarly, other protocols may (optionally) be matched to certain applications (e.g. tel: to start a phone call) on the device, but again only a very specific action can be carried out. It's not possible to simply open any arbitrary desktop application with no specific purpose in mind, no mechanism exists for it.

发布评论

评论列表(0)

  1. 暂无评论