Copy link to clipboard
Copied
Hi,
I have a ColdFusion form; I need this form mail to my email address. I use this line of code:
<FORM METHOD=POST ACTION="mailto:nikoo56@yahoo.com" ENCTYPE="text/plain">
Also I tried <cfform tag too.
It doesn’t give me any error but I'm not getting any email too. Even when I try this code in simple .html page it doesn’t send any email as well. Is there any problem with my computer should I change any setting or does it have any other way make it work.
I really appreciate your help.
Thanks,
Hi There,
Inside the <cfmailpart> tags input your form elements as such:
<cfmailpart type="text"><!--- Comment - Sends a plain text version --->
#form.[element_name]# <!--- Do this for each form element you want sent --->
</cfmailpart>
<cfmailpart type="html"><!--- Comment - Sends and html verson --->
#form.[element_name]# <!--- Do this for each form element you want sent --->
</cfmailpart>
Leonard
Copy link to clipboard
Copied
I think that only works with links. Cold Fusion has a cfmail tag you can use.
Copy link to clipboard
Copied
I have not seen that used in a long time. IIRC, support for it was 'iffy at best.
http://support.microsoft.com/kb/279460
Cold Fusion has a cfmail tag you can use.
+1
CFMail runs on the CF server, so it is not dependent on client configuration like "mailto".
Copy link to clipboard
Copied
Hi,
The following should take care of your situation.
For example purposes, lets say your .cfm page is called: mail_form.cfm
In the body of the mail_form.cfm page, enter the following code structure.
When this page is opened in a browser the first thing displayed is your form.
After completing the form and clicking on the "Send" button, the second part
of the code structure will be processed thus sending an e-mail containing the
input content of the form.
Text inserted between <- Comment -> can be removed when coding into the
page as it is not required for functionality.
Leonard
<== Code Sample To Try ==>
<cfif IsDefined('form.btn_send')>
<=============>
<=============>
<cfmail
to="nikoo56@yahoo.com"
from="[Enter email address]"
subject="[Enter a subject]"
server="mail.servername.com/org/net/us, etc."
username="[Enter approrpiate username - mail server]"
password="[Enter appropriate password - mail server ]">
<cfmailpart type="text"><- Comment - Sends a plain text version
<- Comment - Enter email body content --->
<- Comment - Do not use any html code at all in this section --->
</cfmailpart>
<cfmailpart type="html"><- Comment - Sends and html verson
<- Comment - Enter email body content --->
<- Comment - Can use html code here --->
</cfmailpart>
</cfmail>
<- Comment - By adding the following <cflocation> tag into the process, you reduce
and/or eliminate the chance of multiple e-mails being sent if the page
gets refreshed.
<cflocation url="mail_form.cfm?send_status=Successful" addtoken="no">
<=============>
<=============>
<cfif IsDefined('url.send_status' AND Trim(url.send_status) eq "Successful">
<=============>
<=============>
<- Comment - Enter code to let you know that the process has been processed
successfully ->
<=============>
<=============>
<cfelse>
<=============>
<=============>
<cfform
action="mail_form.cfm"
method="post"
enctype="multipart/form-data"
name="mail_form"
preloader="no"
id="mail_form"
lang="en"
dir="ltr">
<- Comment Form element code here ->
<cfinput
type="submit"
name="btn_send"
id="btn_send_mail"
dir="ltr"
lang="en"
value="Send">
</cfform>
<=============>
<=============>
</cfif>
Copy link to clipboard
Copied
Thanks a lot for the help. It works perfect and send the email but it doesn’t send the form inputs. Email is empty. Is there anything I need to do?
Thanks,
Copy link to clipboard
Copied
Hi There,
Inside the <cfmailpart> tags input your form elements as such:
<cfmailpart type="text"><!--- Comment - Sends a plain text version --->
#form.[element_name]# <!--- Do this for each form element you want sent --->
</cfmailpart>
<cfmailpart type="html"><!--- Comment - Sends and html verson --->
#form.[element_name]# <!--- Do this for each form element you want sent --->
</cfmailpart>
Leonard
Copy link to clipboard
Copied
Thanks a lot Leonard, It works perfect.
Copy link to clipboard
Copied
The easiest way is:
<cfmail type="html"
etc
>
<cfdump var="#form#">
</cfmail>