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
3 Answers
Reset to default 7No, 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
}