从静态页面向单个收件人发送 cf 邮件
Sending cf mail from a static page to single recipient
正在尝试从“联系我们”静态页面发送 <cfmail>
。它将只有一个收件人,我不想将其保存在后端。
<cfcase value="contact">
<cfset caller.mainTitle = "Contact Us">
<div id="contact_form">
<cfform method="post" action="contact2" id="usrform">
First Name<br>
<input class="textbox" type="text" name="firstName" value="First Name" onfocus="if (this.value=='First Name') this.value='';">
<br>
Last Name<br>
<input class="textbox" type="text" name="lastName" value="Last Name" onfocus="if(this.value=='Last Name') this.value ='';">
<br>
Email<br>
<input class="textbox" type="text" name="email" value="Email" onfocus="if(this.value=='Email') this.value='';">
<br>
Phone Number<br>
<input class="textbox" type="text" name="phone" value="Phone Number" onfocus="if(this.value =='Phone Number') this.value='';">
<br>
<input type="submit" class='submitBtn'>
</cfform>
<br>
</div>
<div class="commentsTop">
<p style="color:black; font-size:18px; text-align:left;">We would love to hear from you!<p><br>
<textarea class="comments" rows="10" cols="100" name="comment" form="usrform" onfocus="if(this.value=='Enter your message here...') this.value='';">Enter your message here...</textarea>
</div>
</cfcase>
<cfcase value="contact2">
<cfmail to="test@test.com" from="tester@test.com" Subject="Message From Contact Us" type="HTML">
</cfmail>
</cfcase>
我有一个表格,我想将其作为电子邮件的正文。不确定我是否需要将表格作为 <cfform>
或者这是否无关紧要。
这是我要做的:
我会用普通的html表格(cfform也可以)
对表单进行操作(可以是同一页面,也可以有单独的提交页面。)
在提交页面上,我将编写发送邮件的逻辑。(如果它是简单的邮件发送并且没有发生任何复杂的事情,那么 cfm 页面就可以了,否则 CFC 是首选)
Contactus.cfm
<form method="post" action="submitform.cfm" id="usrform">
First Name<br>
<input class="textbox" type="text" name="firstName" value="First Name" onfocus="if (this.value=='First Name') this.value='';">
<br>
Last Name<br>
<input class="textbox" type="text" name="lastName" value="Last Name" onfocus="if(this.value=='Last Name') this.value ='';">
<br>
Email<br>
<input class="textbox" type="text" name="email" value="Email" onfocus="if(this.value=='Email') this.value='';">
<br>
Phone Number<br>
<input class="textbox" type="text" name="phone" value="Phone Number" onfocus="if(this.value =='Phone Number') this.value='';">
<br>
<input type="submit" class='submitBtn'>
</form>
Submitform.cfm
确保您在 cfmail 中传递正确的凭据和服务器详细信息
<cfmail to="test@test.com" from="tester@test.com" Subject="Message From Contact Us" type="HTML">
<!--- Your message body (you can use your form variable here) --->
FistName: #form.firstName#
LastName: #form.lastName#
</cfmail>
一档解法
<form method="post" action="?">
First Name<br>
<input class="textbox" type="text" name="firstName" value="First Name" onfocus="if (this.value=='First Name') this.value='';">
<br>
Last Name<br>
<input class="textbox" type="text" name="lastName" value="Last Name" onfocus="if(this.value=='Last Name') this.value ='';">
<br>
Email<br>
<input class="textbox" type="text" name="email" value="Email" onfocus="if(this.value=='Email') this.value='';">
<br>
Phone Number<br>
<input class="textbox" type="text" name="phone" value="Phone Number" onfocus="if(this.value =='Phone Number') this.value='';">
<br>
<p style="color:black; font-size:18px; text-align:left;">We would love to hear from you!<p><br>
<textarea class="comments" rows="10" cols="100" name="comment" onfocus="if(this.value=='Enter your message here...') this.value='';">Enter your message here...</textarea>
<input type="submit" class='submitBtn'>
</form>
<cfif cgi.request_method EQ "post">
<cfmail to="test@test.com" from="tester@test.com" Subject="Message From Contact Us" type="HTML">
<!--- Your message body (you can use your form variable here) --->
<cfloop index="i" list="#Form.FieldNames#" delimiters=",">
#i# = #Form[i]#<br>
</cfloop>
</cfmail>
</cfif>
注意:“评论”字段不在表单内
另见:
Display CFLoop Items in Order from Form
正在尝试从“联系我们”静态页面发送 <cfmail>
。它将只有一个收件人,我不想将其保存在后端。
<cfcase value="contact">
<cfset caller.mainTitle = "Contact Us">
<div id="contact_form">
<cfform method="post" action="contact2" id="usrform">
First Name<br>
<input class="textbox" type="text" name="firstName" value="First Name" onfocus="if (this.value=='First Name') this.value='';">
<br>
Last Name<br>
<input class="textbox" type="text" name="lastName" value="Last Name" onfocus="if(this.value=='Last Name') this.value ='';">
<br>
Email<br>
<input class="textbox" type="text" name="email" value="Email" onfocus="if(this.value=='Email') this.value='';">
<br>
Phone Number<br>
<input class="textbox" type="text" name="phone" value="Phone Number" onfocus="if(this.value =='Phone Number') this.value='';">
<br>
<input type="submit" class='submitBtn'>
</cfform>
<br>
</div>
<div class="commentsTop">
<p style="color:black; font-size:18px; text-align:left;">We would love to hear from you!<p><br>
<textarea class="comments" rows="10" cols="100" name="comment" form="usrform" onfocus="if(this.value=='Enter your message here...') this.value='';">Enter your message here...</textarea>
</div>
</cfcase>
<cfcase value="contact2">
<cfmail to="test@test.com" from="tester@test.com" Subject="Message From Contact Us" type="HTML">
</cfmail>
</cfcase>
我有一个表格,我想将其作为电子邮件的正文。不确定我是否需要将表格作为 <cfform>
或者这是否无关紧要。
这是我要做的:
我会用普通的html表格(cfform也可以) 对表单进行操作(可以是同一页面,也可以有单独的提交页面。)
在提交页面上,我将编写发送邮件的逻辑。(如果它是简单的邮件发送并且没有发生任何复杂的事情,那么 cfm 页面就可以了,否则 CFC 是首选)
Contactus.cfm
<form method="post" action="submitform.cfm" id="usrform">
First Name<br>
<input class="textbox" type="text" name="firstName" value="First Name" onfocus="if (this.value=='First Name') this.value='';">
<br>
Last Name<br>
<input class="textbox" type="text" name="lastName" value="Last Name" onfocus="if(this.value=='Last Name') this.value ='';">
<br>
Email<br>
<input class="textbox" type="text" name="email" value="Email" onfocus="if(this.value=='Email') this.value='';">
<br>
Phone Number<br>
<input class="textbox" type="text" name="phone" value="Phone Number" onfocus="if(this.value =='Phone Number') this.value='';">
<br>
<input type="submit" class='submitBtn'>
</form>
Submitform.cfm
确保您在 cfmail 中传递正确的凭据和服务器详细信息
<cfmail to="test@test.com" from="tester@test.com" Subject="Message From Contact Us" type="HTML">
<!--- Your message body (you can use your form variable here) --->
FistName: #form.firstName#
LastName: #form.lastName#
</cfmail>
一档解法
<form method="post" action="?">
First Name<br>
<input class="textbox" type="text" name="firstName" value="First Name" onfocus="if (this.value=='First Name') this.value='';">
<br>
Last Name<br>
<input class="textbox" type="text" name="lastName" value="Last Name" onfocus="if(this.value=='Last Name') this.value ='';">
<br>
Email<br>
<input class="textbox" type="text" name="email" value="Email" onfocus="if(this.value=='Email') this.value='';">
<br>
Phone Number<br>
<input class="textbox" type="text" name="phone" value="Phone Number" onfocus="if(this.value =='Phone Number') this.value='';">
<br>
<p style="color:black; font-size:18px; text-align:left;">We would love to hear from you!<p><br>
<textarea class="comments" rows="10" cols="100" name="comment" onfocus="if(this.value=='Enter your message here...') this.value='';">Enter your message here...</textarea>
<input type="submit" class='submitBtn'>
</form>
<cfif cgi.request_method EQ "post">
<cfmail to="test@test.com" from="tester@test.com" Subject="Message From Contact Us" type="HTML">
<!--- Your message body (you can use your form variable here) --->
<cfloop index="i" list="#Form.FieldNames#" delimiters=",">
#i# = #Form[i]#<br>
</cfloop>
</cfmail>
</cfif>
注意:“评论”字段不在表单内
另见:
Display CFLoop Items in Order from Form