Search code examples
emailcoldfusioncfmailcommonspot

regarding cfmail


I'm using commonspot, and I'm new to it. I have written a code for referring a page to a friend using cfmail. But it is not working, can you please tell me what all i have to do ?

my refer.cfm page

<title>E-Mail this page to your friend</title>

<cfoutput>

<cfform method="post" name="Emailform" action="sendmail.cfm"> 
<table border="0" cellspacing="0" cellpadding="4" width="90%" id="ContactMe">
<tr> 
<td width="30%"><div align="right">Your Name:</div></td> 
<td width="70%"><input type="text" name="name" size="30" /></td> 

<tr> 
<td><div align="right">Friend Email:</div></td> 
<td><input type="text" name="email" size="30" /></td> 

 <tr> 
<td>&nbsp;</td> 
<td> 
<input type="submit" id="submit" name="submit" value="Submit" /> 
<input type="reset" name="reset" value="Reset" /> 
</td>
</table></cfform></cfoutput>

my sendmail.cfm file:

<cfoutput>
<cfmail to="#email#"
from="do-not-reply@balah balah.com"
subject="#form.name# has referred you a page"
type="html">
Dear #form.name#
blah blah
</cfmail>
<p>Your E-Mail has been sent.</p>
</cfoutput>

did I do anything wrong? or did i miss anything?

thank you


Solution

  • If the cfmail call actually has a from address of "do-not-reply@balah balah.com" then it will error due to the space in the email address. If not then you will need to figure out what error is occurring. Wrap your code with the following:

    <cftry>
    <!--- cfmail code here --->
    <cfcatch><cfdump var="#cfcatch#" /><cfabort /></cfcatch>
    </cftry>
    

    I'm not sure from your questions and comments whether the browser is outputting a "nice" error or if you have a custom error message but this try/catch should get around it either way.