WeCodeThings Library
Library of code bits
Glossary    Contact Us
Need a web designer? visit WeCodeThings.Com for more details
Search  
   
Browse by Category


WeCodeThings Library .: ColdFusion .: How to use cfmail with Godaddy using a try | catch



How to use cfmail with Godaddy using a try | catch

  1. <cfparam name="URL.goodemail" default="">
  2. <cfif #URL.goodemail# EQ 'yes'>
  3.         <cftry>
  4. <!--- server="relay-hosting.secureserver.net" AND port = "25" are required for Godaddy servers. --->
  5.  
  6.         <CFMAIL
  7.             server="relay-hosting.secureserver.net"
  8.             port = "25"
  9.             TO="YourEmailAddress@gmail.com"
  10.             FROM= "email@gmail.com"
  11.             SUBJECT= "Email From Potential Customer On Website">
  12.                 <cfmailpart type="html">
  13.                     <cfoutput>
  14.                     This email was sent to your from www.yourwebsite.com via the contact form on the site.  
  15. <br>
  16. ------------------------------------------------------------------------
  17. <br>
  18. <br>
  19.  
  20.                     NAME : #FORM.txtName#
  21.                     <br>
  22.                     <br>
  23.                     EMAIL: #FORM.txtEmail#
  24.                     <br />
  25.                     <br />
  26.                     MESSAGE: #FORM.txtMessage#
  27.                     </cfoutput>
  28.                 </cfmailpart>
  29.         </CFMAIL>
  30.         <cfset mymessage = "Your email has been sent">
  31.         <cfcatch type="any">
  32.          <cfset mymessage = "There was a problem sending your message, please email us directly at YourEmailAddress@gmail.com">
  33.         </cfcatch>
  34.         </cftry>
  35. </cfif>
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43. <!--- BODY --->
  44. -----------------------------------------------------------------------------------------------------------
  45.  
  46. <cfform action="#CGI.SCRIPT_NAME#?goodemail=yes" id="form" name="form">
  47.     <table>
  48.        <tr>
  49.             <td>
  50.                  Your Name:
  51.             </td>
  52.             <td>
  53.                  <cfinput type="text" name="txtName" tooltip="Name is required" validate="maxlength"              validateat="onserver" maxlength="20" message="Name field is required and can have no more than 20 characters in the name field" required="yes">
  54.             </td>
  55.        </tr>
  56.        <tr>
  57.              <td>
  58.                   E-mail Address:
  59.              </td>
  60.              <td>
  61.                   <cfinput type="text" name="txtEmail" message="Please enter a valid email address, This email address will not be used for anything other than returning your comment or question" tooltip="email is required" required="yes"                 validate="email" validateat="onserver">
  62.              </td>
  63.        </tr>
  64.        <tr>
  65.              <td>
  66.                   Message:
  67.              </td>
  68.              <td>
  69.                   <div>
  70.                   <cftextarea        cols="10"
  71.                                             rows="10"
  72.                                             name="txtMessage"
  73.                                             tooltip="Message is Required"
  74.                                             message="You cannot leave the message area blank"
  75.                                             required="yes"
  76.                                             validateat="onserver"
  77.                                             id="txtMessage" />
  78.                   </div>
  79.               </td>
  80.           </tr>
  81.           <tr>
  82.               <td>
  83.                   <cfoutput>#mymessage#</cfoutput>
  84.               </td>
  85.               <td>
  86.  <a href="#" class="style3" onClick="document.getElementById('form').reset()"><strong>reset</strong></a>
  87.               <cfinput name="pressSubmit" type="image" src="images/submitme.gif">
  88.               </td>
  89.           </tr>
  90.     </table>
  91. </cfform>


How helpful was this article to you?

User Comments

Add Comment
Comment J Mearns
5-16-2009 at 5:14pm

Thanks for the Coldfusion on GoDaddy help
Thanks for this post. GoDaddy tech support had no idea how to set up the CFMAIL parameters to send email from their servers.
Comment Joel Hill <wecodethings@gmail.com>
6-5-2009 at 8:10am

Glad to help
@ J Merns

Glad I could help. Yea it took me a while to figure this problem out. You would think that godaddy would no how to send cfmail from their own server? But I guess not




.: Powered by Lore .:Code by WeCodeThings Website Design and Development