|
ColdFusion Home
Basic ColdFusionIntroductionColdFusion Installation ColdFusion Editors ColdFusion Syntax ColdFusion Includes ColdFusion Variables ColdFusion Variable Types ColdFusion If Statements ColdFusion Loops ColdFusion Datasource ColdFusion Database Queries ColdFusion Lists ColdFusion Arrays ColdFusion Redirect ColdFusion Debugging ColdFusion Error Handling Advanced ColdFusionColdFusion MailColdFusion Functions ColdFusion Components ColdFusion Web Services ColdFusion Upload File ColdFusion Read File ColdFusion Write File ColdFusion Append File ColdFusion Rename File ColdFusion Copy File ColdFusion Move File ColdFusion Delete File Cffile Parameters Using cffile Parameters ColdFusion FTP (cfftp) cfftp Cached Connections ColdFusion HTTP (cfhttp) ColdFusion Query of Queries ColdFusion Charts ColdFusion Summary ColdFusion AdminCF AdministratorCF Archive and Deploy CF Scheduled Tasks CF Mini Tutorial ColdFusion BooksColdFusion MX BibleMacromedia ColdFusion MX 7 Web Application Construction Kit FREE Hosting!With every domain name you register with ZappyHost, you get FREE hosting.$1.99 Domain NamesWith every new non-domain purchase thru ZappyHost, you get a domain name for only $1.99. |
ColdFusion Mail (cfmail)You can use ColdFusion's cfmail tag to dynamically send emails to one or more recipients. You might, for example, offer a subscription based email newsletter, or you might like to send users a welcome email when they register on your site. You can build the email dynamically using CFML, so you can personalise things like the message body, the email format (HTML or text) etc Send Email using ColdFusionThis example assumes that a user has just submitted a form, where they were required to fill out their first name and email address. The action page contains the following code (well, realistically you would have more than this on an action page, but let's keep it simple). When this code runs, an email will be sent to the recipient. The recipient's email address and first name have been provided as form variables.
Send Email to Multiple RecipientsIf you have a mailing list, chances are your users' details (email address, first name etc) are in a database. Don't panic - look how easy it is to get these details using ColdFusion! The cfmail tag allows you to loop over the results of a database query. All you need to do is provide the query name using the query attribute.
Sending AttachmentsThe cfmail tag includes the mimeattach attribute. This attribute allows you to specify an attachment, such as a PDF or Word file, to be sent with the email.
How does ColdFusion send email?First of all, you need to have a SMTP (Simple Mail Transfer Protocol) mail server available for your use. You tell ColdFusion which server to use by adding it to your cfmail tag, or by specifying it in the ColdFusion Administrator. In the above example, because we didn't specify a mail server, ColdFusion will use the mail server as specified in the ColdFusion Administrator (assuming that has been done). When this template is executed, ColdFusion will generate a file with a .cfmail extension and place it in the ColdFusion spool folder. ColdFusion polls the spool folder at regular intervals (as specified in the ColdFusion Administrator) to see if any mail messages are queued to be sent. If there are, ColdFusion passes the mail file to the mail server. If the mail server is unavailable (or none has been specified) ColdFusion moves the mail file to the UnDelivr folder. ColdFusion's spool folder and UnDelivr folders are located in the \CFusionMx\Mail folder, or if you are using the J2EE implementation of ColdFusion, the default is the C:\JRun4\servers\{cfusion}\cfusion-ear\cfusion-war\WEB-INF\cfusion\Mail\Undelivr (where {cfusion} is the name of the ColdFusion instance). Via the ColdFusion Adminstrator, you can configure log files to log mail status and errors. These can be useful for troubleshooting any issues you might encounter from time to time. You can also specify the frequency you'd like ColdFusion to poll the spool directory, and if you have the Enterprise version of ColdFusion, you can specify how many threads ColdFusion should use to send mail. This can improve performance enormously, however, you need to make sure the mail server can handle it! Enjoy this website?
Oh, and thank you for supporting Quackit! |
Need Content for your Website?Get unique, quality digital content for your website. You can even earn money by reselling it!Includes:
|