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

jquery - Javascript - Check if email configured - Stack Overflow

programmeradmin0浏览0评论

We can send a mail using mailto: in HTML and JavaScript. Is there any possible method to check if the email is configured (i.e. whether any default email service to send email - such as Outlook - is available)?

I need to handle this

if(emailConfigured == true)

{
    // send mail

} else {

    // give alert
}

We can send a mail using mailto: in HTML and JavaScript. Is there any possible method to check if the email is configured (i.e. whether any default email service to send email - such as Outlook - is available)?

I need to handle this

if(emailConfigured == true)

{
    // send mail

} else {

    // give alert
}
Share Improve this question edited May 20, 2018 at 12:19 Stephen Kennedy 21.6k24 gold badges97 silver badges113 bronze badges asked May 7, 2012 at 14:12 iOSiOS 3,6263 gold badges44 silver badges86 bronze badges 3
  • 1 What do you mean by e-mail configured? – Koen Peters Commented May 7, 2012 at 14:12
  • Btw, if(emailConfigured) is sufficient – Amberlamps Commented May 7, 2012 at 14:13
  • To check whether any default email service to send email, like Outlook is available. – iOS Commented May 7, 2012 at 14:15
Add a ment  | 

3 Answers 3

Reset to default 7

No, you can't do this. It is pletely impossible. The JavaScript environment has no access to the host puter to tell if something is configured to handle mailto: links. That is so far outside the bounds of your webapp's responsibility that you should not and can not worry about it. It's not your page's job to figure out if the user knows how to send emails.

Would it not be possible to use javascript to open new email window and check afterwards if the window changed?

   window.location.assign("mailto:[email protected]?Subject=ABC);

If it the window did not change, you can conclude that the email is not properly configured.

you can add following html if email configured by php or ... and do :

<!-- html -->
<input type="hidden" value="[email protected]" id="mailto" />


// Javascript
if($("#mailto")[0])

{
    // send mail
 window.location = "mailto:"+#("mailto").val();

} else {

    // give alert
}
发布评论

评论列表(0)

  1. 暂无评论