CFEmail – Alternatives for the user

For those times when CFMail Just won’t cooperate, rather than throwing only an error message, give your user a chance to send the email from their own mail client on their PC/device. If CFMail fails the user is provided a link which opens Outlook or which ever Email client has been chosen on their PC.

<cftry>
<cfset mailerr = "Email Sent"><!---default message --->

<!---Send to="#emaillist#"--->
<cfmail
to="#emaillist#"
from="somename@yourdomain.com"
subject="#FORM.subject#"
server="smtp.yourdomain.com"
type="html">
<p>Dear Whoever,<br /><br />
#FORM.comment#</p>
</cfmail>

<cfcatch type="any">
<cfset mailerr = "There was a problem sending the email.">
<a href="mailto:#emaillist#?subject=#subject#&body=#urlEncodedformat(FORM.comment)#">
Webmail System Error: Please click here to send a manual Email via your PC.</a>
</cfcatch>
</cftry>

Then output the mailerr

Cup size   
Select size then click on coffee cup.
This entry was posted in Code, Coldfusion, Problems & Fixes, Snippets and tagged , , , . Bookmark the permalink.