Question
craping my mailling list
hi i have a mailing list issue what i am trying to achieve is
send the mail after every 5 seconds, but due to some reason the
mails are not going..
i am using a field to active to set the status of the emails to 1 which are send and then making a check with with maillist NEQ 0 go to finish.cfm page, to show emails went successfully..
here is below my code which is causing atrouble to me..
<!--- <cfdump var="#url#"> --->
<!--- <cfquery datasource="#request.dsn#" username="#request.username#" password="#request.password#" name="gavy">
Insert into tempnewsletter(tempID,name,email) select * FROM newsletter_subscriptions
</cfquery>
--->
<cfset variables.errArray=ArrayNew(2)>
<!---
set the email address and server of the poor sap who gets
the email listing all of the errors. A way to make this
more robust is to keep the data in a database and simply
notify the designated sap that errors exist to review.
There are MANY useful things you can do with this error
information.
--->
<cfset variables.errEmail="no@mydomain.com">
<cfset variables.errServer="mail.mydomain.com">
<!---
Run Rate is the number of seconds between refresh.
--->
<cfset variables.RunRate=5>
<!---
Query Run is the number of query rows (email addresses)
that will be processed on each execution of this template
--->
<cfset variables.QueryRun=5>
<!---
pull the ID field so we can get a record count.
--->
<cfquery name="MailList" datasource="#dsn#">
select *
from news
</cfquery>
<!---
Do some stuff to prevent page caching, which was found to
be a problem on some client browsers
--->
<cfheader
name="Expires"
value="#now()#">
<cfheader
name="Pragma"
value="no-cache">
<cfheader
name="cache-control"
value="no-cache, no-store, must-revalidate">
<!---
Are we there yet?
--->
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
<cfif MailList.active NEQ 0>
<!---
yes. Notify the email if there are any errors
--->
<cfif not ArrayIsEmpty(variables.errArray)>
<!---
The array is not empty so there must be errors. Send the
error email.
--->
<cfmail
to="yes@mydomain.com"
from="#variables.errEmail#"
subject="OOPS!"
server="#variables.errServer#"
type="HTML">
Errors List<br>
<b>#variables.errArray#</b>
</cfmail>
</cfif>
<!---
finish the job by showing the "All Done" screen.
--->
<cflocation addtoken="no" url="finish.cfm">
<cfelse>
<!---
display the "in-progress" page
--->
<html>
<cfoutput>
<!---
This next line re-runs the template automatically at the run rate.
Note the UUID inserted into the url.
--->
<meta
http-equiv="REFRESH" content="#variables.RunRate#;URL=#cgi.script_name#?UniqueURL=#UrlEncodedFormat(CreateUUID())#">
</cfoutput>
<head><title>Mass Emailer</title></head>
<!---
Send the actual mail.
--->
<!--- <cfparam name="getfileID" default="1"> --->
<!--- <cfdump var="#url#"> --->
<cfloop query="MailList" startrow="1" endrow="#variables.QueryRun#">
<cftry>
<cfquery name="sendnewsletters" datasource="#dsn#">
select *
from list
where id in (#url.newsid#)
</cfquery>
<Cfset emaillist = valuelist(MailList.email)>
<Cfset emailidlist = valuelist(MailList.id)>
<!--- <cfdump var="#emaillist#"> --->
<cfset a = "#listgetat(emaillist, b)#">
<cfdump var = "#a#">
<cfloop from="1" to="#listlen(emaillist)#" index="B">
<cfmail to="#listgetat(emaillist, b)#" from="yes@mydomain.com" subject="#sendnewsletters.subject#" type="HTML" server="mail.mydomain.com" failto="no@mydomain.com">
<link href="_newsletter/style.css" rel="stylesheet" type="text/css">
<table width="747" border="0" align="center" class="border">
<tr>
<td><div align="center"><img src="_images/logo.gif" width="235" height="56" border="0" /></a></div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>» <cfoutput><span class="text">#ActivateURL(sendnewsletters.header,'_blank')#</span></cfoutput></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>» <font color="4D74B2" class="text"><cfoutput>#ActivateURL(sendnewsletters.subject,'_blank')#</cfoutput></font></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><div align="center">Welcome</div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><span class="text"><cfoutput>#ActivateURL(sendnewsletters.update_header,'_blank')#</cfoutput></span></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><cfoutput><span class="text">#ActivateURL(sendnewsletters.new_update,'_blank')#</span></cfoutput></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><cfoutput><span class="text">#ActivateURL(sendnewsletters.body,'_blank')#</span></cfoutput></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</tr>
<tr align="center" valign="top">
<td><a href="unsubscribe.cfm?unsubscribe=#listgetat(emailidlist,b)#">Unsubscribe</a></td>
</tr>
</table>
</cfmail>
</cfloop>
<cfcatch type="ANY">
<!---
if the cfmail statement throws an error it gets dealt with
here. First we append the ID and email address to the error
array.
--->
<cfset arrayAppend(variables.errArray[1],MailList.ID)>
<cfset arrayAppend(variables.errArray[2],MailList.email)>
</cfcatch>
</cftry>
<!---
now that the mail has either been sent or flagged as bad, delete
its database record
--->
<cfquery
datasource="#dsn#">
Update news
set active = 1
Where
ID =
<cfqueryparam
cfsqltype="CF_SQL_NUMERIC"
value="#MailList.ID#">
</cfquery>
</cfloop>
<!---
give the user a visual cue as to where the operation is at the moment.
You can get quite fancy here with pretty html and time-to-completion
calculations based on your record count, refresh rate etc.
--->
<cfset variables.LeftToGo=MailList.RecordCount-variables.QueryRun>
<cfoutput>
<p><b>Total left to send: #variables.LeftToGo#</b>.</p>
<p>Each run is #variables.RunRate# seconds apart.</p>
</cfoutput>
<p>Leave this system alone and wait for this job to complete.</p>
<p>Do not refresh the screen and do not Close it </p>
<p>When it finishes, you will be notified.</p>
</body></html>
</cfif>
if someone have some experience using this please help me out
Thanks
it had made me cry
i am using a field to active to set the status of the emails to 1 which are send and then making a check with with maillist NEQ 0 go to finish.cfm page, to show emails went successfully..
here is below my code which is causing atrouble to me..
<!--- <cfdump var="#url#"> --->
<!--- <cfquery datasource="#request.dsn#" username="#request.username#" password="#request.password#" name="gavy">
Insert into tempnewsletter(tempID,name,email) select * FROM newsletter_subscriptions
</cfquery>
--->
<cfset variables.errArray=ArrayNew(2)>
<!---
set the email address and server of the poor sap who gets
the email listing all of the errors. A way to make this
more robust is to keep the data in a database and simply
notify the designated sap that errors exist to review.
There are MANY useful things you can do with this error
information.
--->
<cfset variables.errEmail="no@mydomain.com">
<cfset variables.errServer="mail.mydomain.com">
<!---
Run Rate is the number of seconds between refresh.
--->
<cfset variables.RunRate=5>
<!---
Query Run is the number of query rows (email addresses)
that will be processed on each execution of this template
--->
<cfset variables.QueryRun=5>
<!---
pull the ID field so we can get a record count.
--->
<cfquery name="MailList" datasource="#dsn#">
select *
from news
</cfquery>
<!---
Do some stuff to prevent page caching, which was found to
be a problem on some client browsers
--->
<cfheader
name="Expires"
value="#now()#">
<cfheader
name="Pragma"
value="no-cache">
<cfheader
name="cache-control"
value="no-cache, no-store, must-revalidate">
<!---
Are we there yet?
--->
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
<cfif MailList.active NEQ 0>
<!---
yes. Notify the email if there are any errors
--->
<cfif not ArrayIsEmpty(variables.errArray)>
<!---
The array is not empty so there must be errors. Send the
error email.
--->
<cfmail
to="yes@mydomain.com"
from="#variables.errEmail#"
subject="OOPS!"
server="#variables.errServer#"
type="HTML">
Errors List<br>
<b>#variables.errArray#</b>
</cfmail>
</cfif>
<!---
finish the job by showing the "All Done" screen.
--->
<cflocation addtoken="no" url="finish.cfm">
<cfelse>
<!---
display the "in-progress" page
--->
<html>
<cfoutput>
<!---
This next line re-runs the template automatically at the run rate.
Note the UUID inserted into the url.
--->
<meta
http-equiv="REFRESH" content="#variables.RunRate#;URL=#cgi.script_name#?UniqueURL=#UrlEncodedFormat(CreateUUID())#">
</cfoutput>
<head><title>Mass Emailer</title></head>
<!---
Send the actual mail.
--->
<!--- <cfparam name="getfileID" default="1"> --->
<!--- <cfdump var="#url#"> --->
<cfloop query="MailList" startrow="1" endrow="#variables.QueryRun#">
<cftry>
<cfquery name="sendnewsletters" datasource="#dsn#">
select *
from list
where id in (#url.newsid#)
</cfquery>
<Cfset emaillist = valuelist(MailList.email)>
<Cfset emailidlist = valuelist(MailList.id)>
<!--- <cfdump var="#emaillist#"> --->
<cfset a = "#listgetat(emaillist, b)#">
<cfdump var = "#a#">
<cfloop from="1" to="#listlen(emaillist)#" index="B">
<cfmail to="#listgetat(emaillist, b)#" from="yes@mydomain.com" subject="#sendnewsletters.subject#" type="HTML" server="mail.mydomain.com" failto="no@mydomain.com">
<link href="_newsletter/style.css" rel="stylesheet" type="text/css">
<table width="747" border="0" align="center" class="border">
<tr>
<td><div align="center"><img src="_images/logo.gif" width="235" height="56" border="0" /></a></div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>» <cfoutput><span class="text">#ActivateURL(sendnewsletters.header,'_blank')#</span></cfoutput></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>» <font color="4D74B2" class="text"><cfoutput>#ActivateURL(sendnewsletters.subject,'_blank')#</cfoutput></font></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><div align="center">Welcome</div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><span class="text"><cfoutput>#ActivateURL(sendnewsletters.update_header,'_blank')#</cfoutput></span></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><cfoutput><span class="text">#ActivateURL(sendnewsletters.new_update,'_blank')#</span></cfoutput></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><cfoutput><span class="text">#ActivateURL(sendnewsletters.body,'_blank')#</span></cfoutput></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</tr>
<tr align="center" valign="top">
<td><a href="unsubscribe.cfm?unsubscribe=#listgetat(emailidlist,b)#">Unsubscribe</a></td>
</tr>
</table>
</cfmail>
</cfloop>
<cfcatch type="ANY">
<!---
if the cfmail statement throws an error it gets dealt with
here. First we append the ID and email address to the error
array.
--->
<cfset arrayAppend(variables.errArray[1],MailList.ID)>
<cfset arrayAppend(variables.errArray[2],MailList.email)>
</cfcatch>
</cftry>
<!---
now that the mail has either been sent or flagged as bad, delete
its database record
--->
<cfquery
datasource="#dsn#">
Update news
set active = 1
Where
ID =
<cfqueryparam
cfsqltype="CF_SQL_NUMERIC"
value="#MailList.ID#">
</cfquery>
</cfloop>
<!---
give the user a visual cue as to where the operation is at the moment.
You can get quite fancy here with pretty html and time-to-completion
calculations based on your record count, refresh rate etc.
--->
<cfset variables.LeftToGo=MailList.RecordCount-variables.QueryRun>
<cfoutput>
<p><b>Total left to send: #variables.LeftToGo#</b>.</p>
<p>Each run is #variables.RunRate# seconds apart.</p>
</cfoutput>
<p>Leave this system alone and wait for this job to complete.</p>
<p>Do not refresh the screen and do not Close it </p>
<p>When it finishes, you will be notified.</p>
</body></html>
</cfif>
if someone have some experience using this please help me out
Thanks
it had made me cry
