Brad Kennedy
asked on
Can't send email using cfc and <cfmail>
I have a flash movie calling this cfc. The insert the record into the database part works OK, but the <cfmail> does not. What's wrong?
<cffunction name="InsertNewComment" access="remote" returntype="string" hint="Add new comment">
<!--- Define required parameters --->
<cfargument name="FirstName" type="string" required="yes">
<cfargument name="LastName" type="string" required="yes">
<cfargument name="Email" type="string" required="yes">
<cfargument name="Message" type="string" required="yes">
<!--- Insert new record into the Database --->
<cfquery datasource="boxoroxnet" username="boxoroxnet" password="Qm4ba27d">
INSERT INTO email_ (FirstName, LastName, Email, Date, Message)
VALUES('#FirstName#','#Las tName#','# Email#',#N ow()#,'#Me ssage#')
</cfquery>
<cfmail
from="info@lfoo.com"
to="foo@foo.com"
subject="Message">
content here
</cfmail>
<!--- Specify result as string --->
<cfset result="Thank you! You'll receive a response from fooFoo shortly.">
<!--- Return result of the function --->
<cfreturn result>
</cffunction>
<cffunction name="InsertNewComment" access="remote" returntype="string" hint="Add new comment">
<!--- Define required parameters --->
<cfargument name="FirstName" type="string" required="yes">
<cfargument name="LastName" type="string" required="yes">
<cfargument name="Email" type="string" required="yes">
<cfargument name="Message" type="string" required="yes">
<!--- Insert new record into the Database --->
<cfquery datasource="boxoroxnet" username="boxoroxnet" password="Qm4ba27d">
INSERT INTO email_ (FirstName, LastName, Email, Date, Message)
VALUES('#FirstName#','#Las
</cfquery>
<cfmail
from="info@lfoo.com"
to="foo@foo.com"
subject="Message">
content here
</cfmail>
<!--- Specify result as string --->
<cfset result="Thank you! You'll receive a response from fooFoo shortly.">
<!--- Return result of the function --->
<cfreturn result>
</cffunction>
Well, since you haven't specified any servers. Is your mail server setup in ColdFusion administrator and does it verify?
Also try checking the ColdFusion logs, as if this is getting an error you wont see it, but will see it in the logs.
C:\ColdFusion8\logs\
C:\ColdFusion8\logs\
ASKER
Mail is set up in CF Admin. Other templates on this site are able to send email.
When I run the code
<cfmail
from="info@lfoo.com"
to="foo@foo.com"
subject="Message">
content here
</cfmail>
in a separate cf page (mail_test.cfm) in the same directory as the cfc, the email gets sent.
Using mail_test.cfm, the CF Admin mailsent.log reports Mail"Message sent from info@foo.com To; foo@foo.com was successfully sent using ..."
When I copy and paste the same code into the function, no email is sent.
mail.sent reports nothing, and mail.log reports no errors. The database insert always works, however.
When I run the code
<cfmail
from="info@lfoo.com"
to="foo@foo.com"
subject="Message">
content here
</cfmail>
in a separate cf page (mail_test.cfm) in the same directory as the cfc, the email gets sent.
Using mail_test.cfm, the CF Admin mailsent.log reports Mail"Message sent from info@foo.com To; foo@foo.com was successfully sent using ..."
When I copy and paste the same code into the function, no email is sent.
mail.sent reports nothing, and mail.log reports no errors. The database insert always works, however.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.