immediate email notification of privatemsg per message - COLDFUSION
Fusion_Sushi - July 13, 2006 - 01:36
Here it is ladies and gentlemen, what you've all been waiting for: now, when your users are sent a prvitmsg they are notified by email immediately of their waiting message. Though this is a first release, this script has been tested and is running on my site right now.
I have two modules written for Drupal, in Coldfusion both live:
1) Filterable user directory
2) Notification of privatemsg
Install notes:
Call this with CFSchedule, interval= 300 or whatever you'd like
Add a field to your privatemsg db called "remind" varchar 10, set default value to 0
ver. 1.0
Drupal/Coldfusion hosting provided by: http://www.hostnexus.com/
<CFQUERY NAME="getlist" DATASOURCE="dbname" >
select id
FROM privatemsg
where newmsg = 1
and remind = 0
</cfquery>
<cfset ar = ValueList(getlist.id)>
<cfloop list='#ar#' index='i'>
<cftry>
<CFQUERY NAME="getmail" DATASOURCE="dbname" >
select *
FROM privatemsg
where id = #i#
</cfquery>
<CFQUERY NAME="getyou" DATASOURCE="dbname" >
select *
FROM users
where uid = '#getmail.recipient#'
</cfquery>
<cftry>
<CFQUERY NAME="getauthor" DATASOURCE="dbname" >
select *
FROM users
where uid = '#getmail.author#'
</cfquery>
<cfcatch>
author error<br>
</cfcatch>
</cftry>
<!---Mail the message--->
<cfmail mailerID = "domain.com custom mailer" type="text"
cc = ""
bcc = ""
to = "#getyou.mail#"
from = "A New Message <noreply@domain.com>"
subject = "New personal message from #getauthor.name# at companyname"
username= ""
password= ""
server= "mail.domain.com">
<cfmailpart type="text" >
<cfoutput>
Hi #getyou.name#
You've got a new message from #getauthor.name# on domain.com!
You have a new message: #getmail.subject#
Click here to read your message:
http://domain.com/privatemsg/view/#i#
Click here to invite a friend to join:
http://domain.com/invite/
-------------------------
We have sent you this notification to facilitate your use as a member of the domain.com service.
Copyright, 2006 domain.com. All Rights Reserved.
</cfoutput>
</cfmailpart>
</cfmail>
<cftry>
<CFQUERY NAME="setstatus" DATASOURCE="dbname">
UPDATE privatemsg
SET remind = "1"
where id = '#i#'
</CFQUERY>
update ok - <cfoutput>#i#</cfoutput> <br>
<cfcatch>
update fail - <cfoutput>#i#</cfoutput> <br>
</cfcatch>
</cftry>
<cfcatch>
loop error<br>
</cfcatch>
</cftry>
</cfloop>