0

Dear Experts,

Apparently using the html mailto: action is prone to not working if the users client side email is not properly configured (like hotmail or other web based email apps). Is it possible to catch this error in the html code (via javascript, PHP, or HTML) and take other actions like re-direct to an FORM, so the user does not think the website is broken and goes somewhere else.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Airshow
0

John,

You could try something like this:

function sendEmail(address, subject, body){
	//based on http://www.webmasterworld.com/javascript/3290040.htm
	if(!address){ return; }
	var q = [];
	address += (subject||body) ? '?' : '';
	if(subject){ q.push('subject=' + subject); }
	if(body){ q.push('body=' + body); }
	var mailto_link = 'mailto:' + address + q.join('&');
	addMessage(mailto_link);
	try{
		win = window.open(mailto_link,'emailWindow');
		if(win && win.open && !win.closed) win.close();
	}
	catch(e){
		//alternative action
	}
}

The success depends on whether all/any types of email failure generate a javascript error.

I would guess that my code should trap complete failures but not all types of error; eg. hotmail will probably open a browser window inviting user to register, but not give an error.

I tried to stimulate an error by changing browser settings (IE6 under Win 2000) but failed to get one. Maybe this is promising, but does not help in testing the error handling. You may need to get imaginative.

Airshow

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.