• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Coldfusion emails

Participant ,
Feb 19, 2008 Feb 19, 2008

Copy link to clipboard

Copied

Hi all...

I am looking for a better technique for sending emails via CF. What I've done so far is used <cfmail to generate emails. I used <cfloop to send email to all email addresses in the db since email content differ from user to user. Let me tell you right away that what we send is not SPAM in any way, these are valid email with info that users are asking for, so you're not contributing here to something bad!
With that sad I am just looking around to see if there are any better ways of sending large number of emails.
One thing that I've ran into when sending unverified email accounts is that if the email address is bad my process will error out and stop. Is there anyway to avoid this when sending?
Also I was wondering about the process where you actually write cfmail files directly to spool folder of CF, is this practical, recomended?
Give me your thoughts from your experience!
TOPICS
Advanced techniques

Views

898

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 19, 2008 Feb 19, 2008

Copy link to clipboard

Copied

Cold Fusion has a validate function which checks the email format. The best time to use it is before you store the address in your db.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 19, 2008 Feb 19, 2008

Copy link to clipboard

Copied

why are you looping through it the CFmail tag has a query element which you can use.

Quick example of how we use it:

<cfquery name="emails" datasource="mssqlcf_name">
SELECT regID, reg_name, reg_email
FROM dbo.Newsletter_Reg
ORDER BY reg_name ASC
</cfquery>

<cfmail query="emails" to="#reg_email#" from="optin@name.com" Subject="#form.subject#" replyto="optin@name.com" type="html" spoolenable="yes">
<cfinclude template="newsletter_files/#sendnews.temp_name#.txt">
</cfmail>

this send out a newsletter to everyone in the emails table. No need for looping.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 19, 2008 Feb 19, 2008

Copy link to clipboard

Copied

I guess cuz each user gets different email content! So do you think it would be better to create email body text file for each user and then sending it your way? Just keep in mind we're talking about thousands of email everyday, on some days over 100K!
Thank you for your help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 19, 2008 Feb 19, 2008

Copy link to clipboard

Copied

Anyone?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 19, 2008 Feb 19, 2008

Copy link to clipboard

Copied

How are you currently determining the content for each user? Is it something that can be generated from query results?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 19, 2008 Feb 19, 2008

Copy link to clipboard

Copied

Could you also put a CFTRY around the CFMAIL tag to catch the error if the email is not valid? If it got caught, you could flag that record as invalid so you don't have to try it again next time you email is sent.

Dan's suggestion of validating the email before storing is a good. I've also validated it just before I send the mail in the cases where I don't control the data entry. This validation would be done instead of the CFTRY.

As far as how to generate the mail message on the fly, I'm with Dan in trying to get the info you need based on a query. If the info is in the query results, you can just drop it in. Maybe you can store the email text in the database. I've also used include files in the past for generating the body of the email...

Hope that helps!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

Hey guys thanks allot for your help!
Each user has their own settings so depending on those I generate email from the dB. I guess validating email is not my biggest concern since I do have some validations in place, I was looking more for "best practices" when comes to sending out large number of emails.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

I don't know if it is a best practice, but one thing that I do for a similar tool I've created is send the emails out in smaller batches.

I have a queue DB table that stores emails to be sent. I then have a CF Scheduled task that runs every 15 minutes. It takes the next X number of emails and sends them, then removes them from the send queue and enters them in the sent table. This way, we didn't overtax our email server with giant blasts of thousands of emails all at once...

Again, not sure about best practicies, but our IT guys was much happier when we didn't bombard his email server with thousands of messages at once.

However, it does mean that the messages take longer to go out...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 21, 2008 Feb 21, 2008

Copy link to clipboard

Copied

LATEST
Hi,
You can try the Asynchronous call in CF to send the emails so that the mails will be sent as a background process.

Prasanth

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation