BeginnerHow can I attach multiple files using cfmail? To add multiple attachments, you must use cfmailparam within your cfmail tags. The below example is from the documentation in cf studio. <cfmail from="peter@domain.com" to="paul@domain.com" subject="Attachments"> <cfmailparam name="Reply-To" value="mary@domain.com"> Please read the text file and view the new logo, and let us know what you think. <cfmailparam file="c:\work\readme.txt"> <cfmailparam file="c:\work\logo.gif"> </cfmail> In addition to sending attachments, you can specify all kinds of headers with the CFMAILPARAM tag as well. How can I resend e-mails that have not been sent and left in the CFUSION\MAIL\UNDELIVR folder? Simply move the .tmp files back in to the CFUSION\MAIL\SPOOL folder and ColdFusion will attempt to send them (it may take a several minutes). How can you BCC someone using cfmail? If your site is hosted on a server with ColdFusion Server 4.5 installed, you can use the BCC attribute in the CFMAIL tag. If the server is running ColdFusion Server 4.0 or earlier, look into the CFX_Mail2 custom tag at http://www.fuseware.com/ How do I make a cfmail display friendly e-mail addresses? <cfmail from="John Smith <jon@smith.com>" to="List Members <members@mylist.com>" subject="List Mailing">Your e-mail here</cfmail> If you want to include parentheses in the name, escape them with backslashes, like this <cfmail from="John Smith \(at work\) <jon@smith.com>" to="List Members <members@mylist.com>" subject="List Mailing">Your e-mail here</cfmail> What alternatives exist for the cfmail tag? CFX_Mail AdvancedHow can I create an HTML e-mail that contains both plain text and HTML sections? <!--- Create a unique ID for the message boundary. ---> <cfset boundary = CreateUUID()> <!--- Standard CFMAIL.. Note that the TYPE attribute is not set. ---> <cfmail to="seth@sethbienek.com" from="seth@sethbienek.com" subject="test"> <!--- This message is going to be a multipart message. Since an email is really just a really long string of text, we need a unique substring to use as a seperator between the parts. Just to make sure that a seperator doesn't accidentally get typed in, I like to use a UUID - the odds of this exact string accidentally coming through in an email would be extremely rare. The mailparam tag will insert the value of the seperator into the mail header, as well as telling the email client that this message is composed of more than one part. ---> <cfmailparam name="Content-Type" value="multipart/alternative; boundary=""#boundary#"""> <!--- Boundaries are always preceded by "--". Each part of a multi-part message is preceded by a boundary. The boundary value MUST match the value set in the header. ---> --#boundary# <!--- Each section of the email gets it's own mini-header. This header tells the mail client what kind of data follows (plain text, 8 bit, in this case), and is always seperated from the content that follows by one empty line. ---> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit This is the plain text message for the email. <!--- Every section gets a header, and every header begins with the same exact Boundary value. ---> --#boundary# <!--- Modern mail clients that support HTML email will ignore a plain text section of an email if there is also an HTML section. Note the empty line between the secion header and the content that follows it. ---> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!--- HTML formatted emails should generally be treated the same as html pages. Javascript is not allowed, however. The "title" tags are not supported in most mail readers, but should be used anyway. ---> <html> <head> <title>HTML Message</title> </head> <body> This is the HTML text message for the email. </body> </html> <!--- The final boundary is always followed by two hyphens. This is how the email client knows that the message is complete, and not to expect another section. ---> --#boundary#-- </cfmail>How can I embed an image in an HTML e-mail? The image should be in the same folder as the page, or adjust the CFFILE tag accordingly. <cfmail to="me@mydomain.com" from="me@mydomain.com" subject="test image"> <cfmailparam name="mime-version" value="1.0"> <cfmailparam name="content-type" value='multipart/alternative; boundary="------------7C252360672B03A0BAD013A5"'> --------------7C252360672B03A0BAD013A5 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This is the text version. Blah... --------------7C252360672B03A0BAD013A5 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <html><body> This is the HTML version. <IMG src="cid:003a01c11b56$c06b9d20$1a01a8c0@test.com"> </body></html> --------------7C252360672B03A0BAD013A5 Content-Type: image/gif; name="myimage.gif" Content-Transfer-Encoding: base64 Content-ID: <003a01c11b56$c06b9d20$1a01a8c0@test.com> <cffile action="read" file="#expandpath('myimage.gif')#" variable="charData"> <cfset data64 = toBase64(charData)>#data64# --------------7C252360672B03A0BAD013A5-- -- End -- </cfmail>How can you immediately delete a cfmail attachment? CFMail includes a line in the spool file that has the name of the file only. Then, when the process that actually sends the email opens the spool file, it does the MIME encoding of the attachment. Thus, if the file has already been deleted, no attachment. Download CFX_ODSMail from http://www.coolfusion.com/. This does multi-file attachments on the fly and stores the attachments in the spoll file. After calling CFX_ODSMail you can delete the file right away. It's freeware. What are the performance limitations of cfmail? The highest throughput you can get is 400 emails per minute, based on the fact that the CF server spools 100 every 15 seconds to the mail server. That's if you increase the spool setting from the default of 60 seconds from the Administrator. Also, there is a 65,535 message limit, based on the spool file naming convention. It appears that the files stored in the Spool directory are named using a hex naming convention of 0000.cfmail to FFFF.cfmail. When we recently sent more mails than the spool directory can handle (65535) the page crashed. HTML formatted e-mails should contain a plain text e-mail and an HTML formatted e-mail together. E-mail clients that can display the HTML version will; those that can't will simple display the plain text e-mail. ColdFusion HTML e-mails don't have two parts - they only contain the HTML e-mail. Using the CF_HtmlMail custom tag, you can send an email that contains an HTML formatted message AND a plain text message. If the browser knows what to do with the HTML tags, it will display the HTML message. If it doesn't, it will display the plain text message - the email client chooses automatically. |
浙公网安备 33010602011771号